from typing import Optional

from sqlalchemy import BigInteger, Boolean, Column, Date, DateTime, Index, Integer, JSON, Numeric, PrimaryKeyConstraint, Sequence, SmallInteger, String, Table, Text, UniqueConstraint, text
from sqlalchemy.dialects.postgresql import TIMESTAMP
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
import datetime
import decimal

class Base(DeclarativeBase):
    pass


class AAJsonTest(Base):
    __tablename__ = 'a_a_json_test'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='a_a_json_test_pkey'),
        {'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment='主键')
    json_request: Mapped[Optional[dict]] = mapped_column(JSON, comment='json请求')
    json_response: Mapped[Optional[dict]] = mapped_column(JSON, comment='json响应')
    fmemo: Mapped[Optional[str]] = mapped_column(String(200), comment='备注')


t_a_job_detail = Table(
    'a_job_detail', Base.metadata,
    Column('fsceneno', Integer, nullable=False, comment='场景编号 '),
    Column('fpoint_no', String(20), nullable=False, comment='教室编号'),
    Column('fentryid', Integer, nullable=False, comment='行号'),
    Column('ftype', String(2), comment='指令: S/灯, H/红外,C/窗帘,K/空开'),
    Column('finstructions', String(1024), nullable=False, comment='指令'),
    Column('fmacno', String(32), comment='设备序列号'),
    Column('flinkmark', String(20), comment='设备第X只脚'),
    Column('factiontype', Integer, comment='指令类型：1/超标，2/达标'),
    Column('fip', String(20), comment='设备IP地址'),
    Column('fport', String(10), comment='设备IP端口'),
    Column('fequipmenttype', Integer, comment='设备类型'),
    Index('ix_a_job_detail', 'fsceneno', 'fpoint_no', 'fentryid'),
    schema='public',
    comment='场景执行脚本'
)


class AJobHead(Base):
    __tablename__ = 'a_job_head'
    __table_args__ = (
        PrimaryKeyConstraint('fsceneno', 'fpoint_no', name='a_job_head_pkey'),
        {'comment': '场景执行主表', 'schema': 'public'}
    )

    fsceneno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='场景编号 ')
    fpoint_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='教室编号')
    factiontype: Mapped[Optional[int]] = mapped_column(Integer, comment='指令类型：1/超标，2/达标')
    fscenetype: Mapped[Optional[int]] = mapped_column(Integer, comment='场景类型')


class AJobState(Base):
    __tablename__ = 'a_job_state'
    __table_args__ = (
        PrimaryKeyConstraint('fsceneno', 'fpoint_no', name='a_job_state_pkey'),
        {'comment': '场景执行', 'schema': 'public'}
    )

    fsceneno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='场景编号 ')
    fpoint_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='教室编号')
    fupddate: Mapped[datetime.datetime] = mapped_column(DateTime, comment='产生时间')


class ATcAirwarring(Base):
    __tablename__ = 'a_tc_airwarring'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='a_tc_airwarring_pkey'),
        Index('ix_a_tc_airwarring', 'fwarringno', 'fsite_no', 'fpoint_no', 'fairitem', 'fgetdate'),
        {'comment': '当前空气报警信息', 'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='编号 ')
    fwarringno: Mapped[int] = mapped_column(Integer, comment='报警编号 ')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='市/区/学校')
    fpoint_no: Mapped[str] = mapped_column(String(20), comment='教室编号')
    fairitem: Mapped[int] = mapped_column(Integer, comment='空气项目')
    fcurnum: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='当前值')
    fbegnum: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='起始值')
    fendnum: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='起讫值')
    fdescribe: Mapped[str] = mapped_column(String(200), comment='报警说明')
    fsendmsg: Mapped[int] = mapped_column(Integer, comment='是否已发送消息')
    fsendemail: Mapped[int] = mapped_column(Integer, comment='是否已发送邮件')
    fgetdate: Mapped[datetime.datetime] = mapped_column(DateTime, comment='产生时间')
    fprocflag: Mapped[Optional[int]] = mapped_column(Integer, server_default=text('0'))
    fenddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime)


class ATcAirwarringUser(Base):
    __tablename__ = 'a_tc_airwarring_user'
    __table_args__ = (
        PrimaryKeyConstraint('fwarringno', 'fuserno', name='a_tc_airwarring_user_pkey'),
        Index('ix_s_tc_smartwarring3', 'fwarringno', 'freadtime'),
        {'comment': '空气报警用户信息', 'schema': 'public'}
    )

    fwarringno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='报警编号')
    fuserno: Mapped[str] = mapped_column(String(20), primary_key=True, comment='用户编号')
    freadtime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='阅读时间')


class ATcEquipwarring(Base):
    __tablename__ = 'a_tc_equipwarring'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='a_tc_equipwarring_pkey'),
        Index('ix_a_tc_equipwarring', 'fwarringno', 'fsite_no', 'fpoint_no', 'fgetdate'),
        {'comment': '设备报警信息', 'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, Sequence('a_tc_airwarring_fentryid_seq', schema='public'), primary_key=True, comment='编号')
    fwarringno: Mapped[int] = mapped_column(Integer, comment='报警编号')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='市/区/学校')
    fpoint_no: Mapped[str] = mapped_column(String(20), comment='教室编号')
    feuipmentid: Mapped[int] = mapped_column(Integer, Sequence('s_ts_equipment_info_feuipmentid_seq', schema='public'), comment='设备ID')
    fequipmentbarcode: Mapped[str] = mapped_column(String(20), comment='固定资产码')
    ferrorno: Mapped[str] = mapped_column(String(20), comment='报警编号')
    fdescribe: Mapped[str] = mapped_column(String(200), comment='报警说明')
    fsendmsg: Mapped[int] = mapped_column(Integer, comment='是否已发送消息')
    fsendemail: Mapped[int] = mapped_column(Integer, comment='是否已发送邮件')
    fgetdate: Mapped[datetime.datetime] = mapped_column(DateTime, comment='产生时间')
    fprocflag: Mapped[Optional[int]] = mapped_column(Integer, server_default=text('0'))


class ATcEquipwarringUser(Base):
    __tablename__ = 'a_tc_equipwarring_user'
    __table_args__ = (
        PrimaryKeyConstraint('fwarringno', 'fuserno', name='a_tc_equipwarring_user_pkey'),
        Index('ix_a_tc_equipwarring_user', 'fwarringno', 'freadtime'),
        {'comment': '设备报警用户信息', 'schema': 'public'}
    )

    fwarringno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='报警编号')
    fuserno: Mapped[str] = mapped_column(String(20), primary_key=True, comment='用户编号')
    freadtime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='阅读时间')


class ATcMonitorDetail(Base):
    __tablename__ = 'a_tc_monitor_detail'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='a_tc_monitor_detail_pkey'),
        {'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='自增长编号')
    fmonitorno: Mapped[int] = mapped_column(Integer, comment='监看编号')
    fequipmenttype: Mapped[int] = mapped_column(Integer, comment='设备类型')
    fpowerstatus: Mapped[int] = mapped_column(Integer, comment='设备电源状态(0.关 1.开)')


class ATcMonitorHead(Base):
    __tablename__ = 'a_tc_monitor_head'
    __table_args__ = (
        PrimaryKeyConstraint('fmonitorno', name='a_tc_monitor_pkey'),
        {'schema': 'public'}
    )

    fmonitorno: Mapped[int] = mapped_column(Integer, Sequence('a_tc_monitor_fmonitorno_seq', schema='public'), primary_key=True, comment='自增长编号')
    ftype: Mapped[int] = mapped_column(Integer, comment='类型(1.假期 2.工作日)')
    begintime: Mapped[str] = mapped_column(String(20), comment='开始时间(01、02、03...)')
    endtime: Mapped[str] = mapped_column(String(20), comment='结束时间(01、02、03...)')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='所属学校')
    fdescribe: Mapped[Optional[str]] = mapped_column(String(200), comment='描述')
    fgetdate: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='产生时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class ATcMonitorPoint(Base):
    __tablename__ = 'a_tc_monitor_point'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='a_tc_monitor_point_pkey'),
        {'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='自增长编号')
    fmonitorno: Mapped[int] = mapped_column(Integer, comment='监看编号')
    fpoint_no: Mapped[str] = mapped_column(String(20))


class ATcOvertime(Base):
    __tablename__ = 'a_tc_overtime'
    __table_args__ = (
        PrimaryKeyConstraint('fid', name='pk_a_tc_overtime'),
        Index('index_a_tc_overtime', 'fsite_no', 'user_id', 'fbegtime', 'fendtime', 'fbillstate'),
        {'comment': '加班申请', 'schema': 'public'}
    )

    fid: Mapped[int] = mapped_column(Integer, Sequence('a_tc_overtime_seq', schema='public'), primary_key=True, comment='自增长')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='客户编号')
    user_id: Mapped[int] = mapped_column(BigInteger, comment='用户编号')
    fbegtime: Mapped[str] = mapped_column(String(5), comment='开始时间')
    fendtime: Mapped[str] = mapped_column(String(5), comment='结束时间')
    fbegdate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='开始日期')
    fenddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='结束日期')
    fnote: Mapped[Optional[str]] = mapped_column(String(80), comment='备注')
    fcheckdate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='审核时间')
    fcheckuser: Mapped[Optional[str]] = mapped_column(String(20), comment='审核员')
    fbillstate: Mapped[Optional[int]] = mapped_column(Integer, comment='单据状态(1:待确认/2:已确认/8:已作废)Ts_Dict=2007')
    fpoint_no: Mapped[Optional[str]] = mapped_column(String(20), comment='实验室编号')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='修改时间')


class ATcPointMoniter(Base):
    __tablename__ = 'a_tc_point_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fpoint_no', 'fmoniter_date', name='a_tc_point_moniter_pkey'),
        {'comment': '监测点上传信息(当天流水信息)', 'schema': 'public'}
    )

    fpoint_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='监测点')
    fmoniter_date: Mapped[datetime.datetime] = mapped_column(DateTime, primary_key=True, comment='监测日期')
    fmoniter_so2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化硫(SO2)')
    fmoniter_no2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化氮(NO2)')
    fmoniter_co: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='一氧化碳(CO)')
    fmoniter_o3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)')
    fmoniter_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='细颗粒物(PM2.5)')
    fmoniter_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='可吸入颗粒物(PM10)')
    faqi: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='AQI')
    fcontaminants: Mapped[Optional[str]] = mapped_column(String(80), comment='首要污染物')
    fmoniter_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内二氧化碳(CO2)')
    fmoniter_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内甲醛')
    fmoniter_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内挥发性有机物')
    fwd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内温度')
    fsd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内湿度')
    faqi2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内AQI')
    fcontaminants2: Mapped[Optional[str]] = mapped_column(String(80), comment='室内首要污染物')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')
    fmacno: Mapped[Optional[str]] = mapped_column(String(20))
    noise: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='噪音')


class ATcPointord(Base):
    __tablename__ = 'a_tc_pointord'
    __table_args__ = (
        PrimaryKeyConstraint('fordno', name='pk_a_tc_pointord'),
        Index('index_a_tc_pointord', 'fpoint_no', 'forddate', 'fbegtime', 'fendtime'),
        {'comment': '会议室预约', 'schema': 'public'}
    )

    fordno: Mapped[str] = mapped_column(String(20), primary_key=True, comment='预约单号')
    fpoint_no: Mapped[str] = mapped_column(String(40), comment='监测点编号')
    forddate: Mapped[datetime.datetime] = mapped_column(DateTime, comment='预约日期')
    fbegtime: Mapped[str] = mapped_column(String(5), comment='预约开始时间')
    fendtime: Mapped[str] = mapped_column(String(5), comment='预约结束时间')
    fcustnum: Mapped[int] = mapped_column(Integer, comment='预约人数')
    forduser: Mapped[str] = mapped_column(String(20), comment='预约人员')
    fordstate: Mapped[int] = mapped_column(Integer, comment='状态(0未审核/1已通过/2已拒绝)')
    fmemo: Mapped[Optional[str]] = mapped_column(String(80), comment='备注')
    fcheckin: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='签到开始时间')
    fcheckout: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='签到结束时间')
    fcheckstate: Mapped[Optional[int]] = mapped_column(Integer, comment='签到状态(0未签到/1已签到)')
    fcheckdate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='审核时间')
    fcheckuser: Mapped[Optional[str]] = mapped_column(String(20), comment='审核员')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')
    fsite_no: Mapped[Optional[str]] = mapped_column(String(20))


class ATcSiteMoniter(Base):
    __tablename__ = 'a_tc_site_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fsite_no', 'fmoniter_date', name='a_tc_site_moniter_pkey'),
        {'comment': '定时各站点统计档(当天流水信息)计算每个小时内：站点、区、省的指标，汇总后刷新 TS_SITE以便界面抓',
     'schema': 'public'}
    )

    fsite_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    fmoniter_date: Mapped[datetime.datetime] = mapped_column(DateTime, primary_key=True, comment='监测日期')
    fmoniter_so2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化硫(SO2)')
    fmoniter_no2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化氮(NO2)')
    fmoniter_co: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='一氧化碳(CO)')
    fmoniter_o3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)')
    fmoniter_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='细颗粒物(PM2.5)')
    fmoniter_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='可吸入颗粒物(PM10)')
    fwd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室外温度')
    fsd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室外湿度')
    faqi: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='AQI')
    fcontaminants: Mapped[Optional[str]] = mapped_column(String(80), comment='首要污染物')
    fmoniter_pm26: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内细颗粒物(PM2.5)')
    fmoniter_pm11: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内可吸入颗粒物(PM10)')
    fmoniter_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内二氧化碳(CO2)')
    fmoniter_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内甲醛')
    fmoniter_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内挥发性有机物')
    fwd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内温度')
    fsd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内湿度')
    faqi2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内AQI')
    fcontaminants2: Mapped[Optional[str]] = mapped_column(String(80), comment='室内首要污染物')
    noise: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='噪音')


class ATdPointMoniter(Base):
    __tablename__ = 'a_td_point_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_date', 'fpoint_no', name='a_td_point_moniter_pkey'),
        {'comment': '每天监测点数据(平均值)', 'schema': 'public'}
    )

    fmoniter_date: Mapped[datetime.datetime] = mapped_column(DateTime, primary_key=True, comment='监测日期')
    fpoint_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='监测点编号')
    fsite_no: Mapped[Optional[str]] = mapped_column(String(40), comment='所属站点')
    farea_no: Mapped[Optional[str]] = mapped_column(String(40), comment='所属地区')
    fmoniter_so2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化硫(SO2)')
    fmoniter_no2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化氮(NO2)')
    fmoniter_co: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='一氧化碳(CO)')
    fmoniter_o3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)')
    fmoniter_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='细颗粒物(PM2.5)')
    fmoniter_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='可吸入颗粒物(PM10)')
    faqi: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='AQI')
    fcontaminants: Mapped[Optional[str]] = mapped_column(String(80), comment='首页污染物')
    fmoniter_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内二氧化碳(CO2)')
    fmoniter_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内甲醛')
    fmoniter_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内挥发性有机物')
    fwd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内温度')
    fsd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内湿度')
    faqi2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内AQI')
    fcontaminants2: Mapped[Optional[str]] = mapped_column(String(80), comment='室内首要污染物')
    fnewwork: Mapped[Optional[str]] = mapped_column(String(10), comment='是否联网')
    fpoint_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')
    fmoniter_o3_1: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3))
    fmoniter_o3_8: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3))
    fmoniter_2_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比细颗粒物(PM2.5)')
    fmoniter_2_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比可吸入颗粒物(PM10)')
    fmoniter_2_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内二氧化碳(CO2)')
    fmoniter_2_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内甲醛')
    fmoniter_2_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内挥发性有机物')
    fwd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内温度')
    fsd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内湿度')


class ATdSiteMoniter(Base):
    __tablename__ = 'a_td_site_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_date', 'fsite_no', name='a_td_site_moniter_pkey'),
        {'comment': '每天站点/区域/市 的情况(平均值)', 'schema': 'public'}
    )

    fmoniter_date: Mapped[datetime.datetime] = mapped_column(DateTime, primary_key=True, comment='监测日期')
    fsite_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    fmoniter_so2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化硫(SO2)')
    fmoniter_no2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化氮(NO2)')
    fmoniter_co: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='一氧化碳(CO)')
    fmoniter_o3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)')
    fmoniter_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='细颗粒物(PM2.5)')
    fmoniter_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='可吸入颗粒物(PM10)')
    faqi: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='AQI')
    fcontaminants: Mapped[Optional[str]] = mapped_column(String(80), comment='首要污染物')
    fmoniter_pm26: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内细颗粒物(PM2.5)')
    fmoniter_pm11: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内可吸入颗粒物(PM10)')
    fmoniter_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内二氧化碳(CO2)')
    fmoniter_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内甲醛')
    fmoniter_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内挥发性有机物')
    fwd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内温度')
    fsd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内湿度')
    faqi2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内AQI')
    fcontaminants2: Mapped[Optional[str]] = mapped_column(String(80), comment='室内首要污染物')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime)
    fmoniter_o3_1: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3))
    fmoniter_o3_8: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3))
    fmoniter_2_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比细颗粒物(PM2.5)')
    fmoniter_2_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比可吸入颗粒物(PM10)')
    fmoniter_2_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内二氧化碳(CO2)')
    fmoniter_2_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内甲醛')
    fmoniter_2_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内挥发性有机物')
    fwd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内温度')
    fsd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内湿度')


class AThPointMoniter(Base):
    __tablename__ = 'a_th_point_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fpoint_no', name='a_th_point_moniter_pkey'),
        {'comment': '监测点上传信息(当天流水信息)', 'schema': 'public'}
    )

    fpoint_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='监测点编号')
    fsite_no: Mapped[Optional[str]] = mapped_column(String(40), comment='所属站点')
    farea_no: Mapped[Optional[str]] = mapped_column(String(40), comment='所属地区')
    fmoniter_so2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化硫(SO2)')
    fmoniter_no2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化氮(NO2)')
    fmoniter_co: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='一氧化碳(CO)')
    fmoniter_o3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)')
    fmoniter_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='细颗粒物(PM2.5)')
    fmoniter_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='可吸入颗粒物(PM10)')
    faqi: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='AQI')
    fcontaminants: Mapped[Optional[str]] = mapped_column(String(80), comment='首页污染物')
    fmoniter_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内二氧化碳(CO2)')
    fmoniter_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内甲醛')
    fmoniter_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内挥发性有机物')
    fwd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内温度')
    fsd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内湿度')
    faqi2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内AQI')
    fcontaminants2: Mapped[Optional[str]] = mapped_column(String(80), comment='室内首要污染物')
    fnewwork: Mapped[Optional[str]] = mapped_column(String(10), comment='是否联网')
    fpoint_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')
    fmoniter_2_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比细颗粒物(PM2.5)')
    fmoniter_2_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比可吸入颗粒物(PM10)')
    fmoniter_2_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内二氧化碳(CO2)')
    fmoniter_2_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内甲醛')
    fmoniter_2_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内挥发性有机物')
    fwd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内温度')
    fsd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内湿度')
    noise: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='噪音')
    fmoniter_pm1: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), server_default=text('0'))


class AThSiteMoniter(Base):
    __tablename__ = 'a_th_site_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fsite_no', 'ftime', name='a_th_site_moniter_pkey'),
        {'comment': '今天每个小时,站点/区域/市 的情况', 'schema': 'public'}
    )

    fsite_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    ftime: Mapped[int] = mapped_column(Integer, primary_key=True, comment='时段')
    fmoniter_so2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化硫(SO2)')
    fmoniter_no2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化氮(NO2)')
    fmoniter_co: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='一氧化碳(CO)')
    fmoniter_o3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)')
    fmoniter_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='细颗粒物(PM2.5)')
    fmoniter_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='可吸入颗粒物(PM10)')
    faqi: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='AQI')
    fcontaminants: Mapped[Optional[str]] = mapped_column(String(80), comment='首要污染物')
    fmoniter_pm26: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内细颗粒物(PM2.5)')
    fmoniter_pm11: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内可吸入颗粒物(PM10)')
    fmoniter_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内二氧化碳(CO2)')
    fmoniter_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内甲醛')
    fmoniter_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内挥发性有机物')
    fwd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内温度')
    fsd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内湿度')
    faqi2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内AQI')
    fcontaminants2: Mapped[Optional[str]] = mapped_column(String(80), comment='室内首要污染物')
    noise: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='噪音')


class AThSmartMoniter(Base):
    __tablename__ = 'a_th_smart_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fmacno', name='a_th_smart_moniter_pkey'),
        {'comment': '设备联网', 'schema': 'public'}
    )

    fmacno: Mapped[str] = mapped_column(String(80), primary_key=True, comment='机器码')
    fnewwork: Mapped[Optional[str]] = mapped_column(String(10), comment='是否联网')
    ftime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='保存时间')


class ATmPointAiritem(Base):
    __tablename__ = 'a_tm_point_airitem'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_month', 'fpoint_no', 'fitem_name', name='a_tm_point_airitem_pkey'),
        {'comment': '月空气指标(站点/区域/市)', 'schema': 'public'}
    )

    fmoniter_month: Mapped[str] = mapped_column(String(6), primary_key=True, comment='监测月份')
    fpoint_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    fitem_name: Mapped[str] = mapped_column(String(40), primary_key=True, comment='空气项目')
    fitem_range: Mapped[Optional[str]] = mapped_column(String(20), comment='范围')
    fitem_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='本月平均')
    ftb_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比值')
    ftb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比升降')
    ftb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='同比旗标')
    fhb_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比值')
    fhb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比升级')
    fhb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='环比旗标')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')


class ATmPointAirquality(Base):
    __tablename__ = 'a_tm_point_airquality'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_month', 'fpoint_no', 'faqi_type', name='a_tm_point_airquality_pkey'),
        {'comment': '月空气质量(室外BOX)', 'schema': 'public'}
    )

    fmoniter_month: Mapped[str] = mapped_column(String(6), primary_key=True, comment='监测月份')
    fpoint_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    faqi_type: Mapped[int] = mapped_column(Integer, primary_key=True, comment='空气质量等级')
    faqi_name: Mapped[Optional[str]] = mapped_column(String(20), comment='空气质量名称')
    faqi_day: Mapped[Optional[int]] = mapped_column(Integer, comment='天数')
    faqi_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='占比')
    ftb_day: Mapped[Optional[int]] = mapped_column(Integer, comment='同比天数')
    ftb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比升降')
    ftb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='同比旗标')
    fhb_day: Mapped[Optional[int]] = mapped_column(Integer, comment='环比天数')
    fhb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比升级')
    fhb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='环比旗标')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')


class ATmPointMoniter(Base):
    __tablename__ = 'a_tm_point_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_month', 'fpoint_no', name='a_tm_point_moniter_pkey'),
        {'comment': '月监测点数据(平均值)', 'schema': 'public'}
    )

    fmoniter_month: Mapped[str] = mapped_column(String(6), primary_key=True, comment='监测日期')
    fpoint_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='监测点编号')
    fsite_no: Mapped[Optional[str]] = mapped_column(String(40), comment='所属站点')
    farea_no: Mapped[Optional[str]] = mapped_column(String(40), comment='所属地区')
    fmoniter_so2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化硫(SO2)')
    fmoniter_no2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化氮(NO2)')
    fmoniter_co: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='一氧化碳(CO)')
    fmoniter_o3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)')
    fmoniter_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='细颗粒物(PM2.5)')
    fmoniter_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='可吸入颗粒物(PM10)')
    faqi: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='AQI')
    fcontaminants: Mapped[Optional[str]] = mapped_column(String(80), comment='首页污染物')
    fmoniter_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内二氧化碳(CO2)')
    fmoniter_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内甲醛')
    fmoniter_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内挥发性有机物')
    fwd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内温度')
    fsd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内湿度')
    faqi2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内AQI')
    fcontaminants2: Mapped[Optional[str]] = mapped_column(String(80), comment='室内首要污染物')
    fnewwork: Mapped[Optional[str]] = mapped_column(String(10), comment='是否联网')
    fpoint_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')
    fmoniter_o3_1: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)1个小时平均')
    fmoniter_o3_8: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)8个小时平均')
    fmoniter_2_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比细颗粒物(PM2.5)')
    fmoniter_2_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比可吸入颗粒物(PM10)')
    fmoniter_2_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内二氧化碳(CO2)')
    fmoniter_2_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内甲醛')
    fmoniter_2_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内挥发性有机物')
    fwd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内温度')
    fsd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内湿度')


class ATmSiteAiritem(Base):
    __tablename__ = 'a_tm_site_airitem'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_month', 'fsite_no', 'fitem_name', name='a_tm_site_airitem_pkey'),
        {'comment': '月空气指标(站点/区域/市)', 'schema': 'public'}
    )

    fmoniter_month: Mapped[str] = mapped_column(String(6), primary_key=True, comment='监测月份')
    fsite_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    fitem_name: Mapped[str] = mapped_column(String(40), primary_key=True, comment='空气项目')
    fitem_range: Mapped[Optional[str]] = mapped_column(String(20), comment='范围')
    fitem_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='本月平均')
    ftb_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比值')
    ftb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比升降')
    ftb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='同比旗标')
    fhb_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比值')
    fhb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比升级')
    fhb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='环比旗标')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')


class ATmSiteAirquality(Base):
    __tablename__ = 'a_tm_site_airquality'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_month', 'fsite_no', 'faqi_type', name='a_tm_site_airquality_pkey'),
        {'comment': '月空气质量(站点/区域/市)', 'schema': 'public'}
    )

    fmoniter_month: Mapped[str] = mapped_column(String(6), primary_key=True, comment='监测月份')
    fsite_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    faqi_type: Mapped[int] = mapped_column(Integer, primary_key=True, comment='空气质量等级')
    faqi_name: Mapped[Optional[str]] = mapped_column(String(20), comment='空气质量名称')
    faqi_day: Mapped[Optional[int]] = mapped_column(Integer, comment='天数')
    faqi_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='占比')
    ftb_day: Mapped[Optional[int]] = mapped_column(Integer, comment='同比天数')
    ftb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比升降')
    ftb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='同比旗标')
    fhb_day: Mapped[Optional[int]] = mapped_column(Integer, comment='环比天数')
    fhb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比升级')
    fhb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='环比旗标')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')


class ATmSiteMoniter(Base):
    __tablename__ = 'a_tm_site_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_month', 'fsite_no', name='a_tm_site_moniter_pkey'),
        {'comment': '月站点/区域/市 的情况(平均值)', 'schema': 'public'}
    )

    fmoniter_month: Mapped[str] = mapped_column(String(6), primary_key=True, comment='监测月份')
    fsite_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    fmoniter_so2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化硫(SO2)')
    fmoniter_no2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化氮(NO2)')
    fmoniter_co: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='一氧化碳(CO)')
    fmoniter_o3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)')
    fmoniter_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='细颗粒物(PM2.5)')
    fmoniter_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='可吸入颗粒物(PM10)')
    faqi: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='AQI')
    fcontaminants: Mapped[Optional[str]] = mapped_column(String(80), comment='首要污染物')
    fmoniter_pm26: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内细颗粒物(PM2.5)')
    fmoniter_pm11: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内可吸入颗粒物(PM10)')
    fmoniter_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内二氧化碳(CO2)')
    fmoniter_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内甲醛')
    fmoniter_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内挥发性有机物')
    fwd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内温度')
    fsd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内湿度')
    faqi2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内AQI')
    fcontaminants2: Mapped[Optional[str]] = mapped_column(String(80), comment='室内首要污染物')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')
    fmoniter_o3_1: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)1个小时平均')
    fmoniter_o3_8: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)8个小时平均')
    fmoniter_2_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比细颗粒物(PM2.5)')
    fmoniter_2_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比可吸入颗粒物(PM10)')
    fmoniter_2_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内二氧化碳(CO2)')
    fmoniter_2_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内甲醛')
    fmoniter_2_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内挥发性有机物')
    fwd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内温度')
    fsd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内湿度')


class ATnPointMoniter(Base):
    __tablename__ = 'a_tn_point_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fpoint_no', 'fmoniter_date', name='a_tn_point_moniter_pkey'),
        {'comment': '学校各室外站点每小时汇总', 'schema': 'public'}
    )

    fpoint_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    fmoniter_date: Mapped[datetime.datetime] = mapped_column(DateTime, primary_key=True, comment='监测日期')
    fmoniter_so2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化硫(SO2)')
    fmoniter_no2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化氮(NO2)')
    fmoniter_co: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='一氧化碳(CO)')
    fmoniter_o3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)')
    fmoniter_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='细颗粒物(PM2.5)')
    fmoniter_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='可吸入颗粒物(PM10)')
    fwd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室外温度')
    fsd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室外湿度')
    faqi: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='AQI')
    fcontaminants: Mapped[Optional[str]] = mapped_column(String(80), comment='首要污染物')
    fmoniter_pm26: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内细颗粒物(PM2.5)')
    fmoniter_pm11: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内可吸入颗粒物(PM10)')
    fmoniter_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内二氧化碳(CO2)')
    fmoniter_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内甲醛')
    fmoniter_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内挥发性有机物')
    fwd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内温度')
    fsd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内湿度')
    faqi2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内AQI')
    fcontaminants2: Mapped[Optional[str]] = mapped_column(String(80), comment='室内首要污染物')
    noise: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='噪音')


class ATpAirswitch(Base):
    __tablename__ = 'a_tp_airswitch'
    __table_args__ = (
        PrimaryKeyConstraint('fno', name='a_tp_airswitch_pkey'),
        {'schema': 'public'}
    )

    fno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='自增长')
    fip: Mapped[str] = mapped_column(String(20), comment='ip')
    fport: Mapped[int] = mapped_column(Integer, comment='port')
    fupddate: Mapped[datetime.datetime] = mapped_column(TIMESTAMP(precision=6), comment='更新时间')
    node: Mapped[str] = mapped_column(String(20), comment='节点')
    voltage: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='电压')
    eleflow: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='电流')
    temperature: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='温度')
    workrate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='功率')
    ele: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='电量')
    fmacno: Mapped[Optional[str]] = mapped_column(String(12), comment='mac')


class ATpAirswitchhy(Base):
    __tablename__ = 'a_tp_airswitchhy'
    __table_args__ = (
        PrimaryKeyConstraint('fno', name='a_tp_airswitch_copy1_pkey'),
        {'schema': 'public'}
    )

    fno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='自增长')
    fip: Mapped[str] = mapped_column(String(20), comment='ip')
    fport: Mapped[int] = mapped_column(Integer, comment='port')
    fupddate: Mapped[datetime.datetime] = mapped_column(TIMESTAMP(precision=6), comment='更新时间')
    node: Mapped[Optional[str]] = mapped_column(String(20), comment='节点')
    fmacno: Mapped[Optional[str]] = mapped_column(String(12), comment='mac')
    baud: Mapped[Optional[int]] = mapped_column(Integer, comment='波特率')
    gvoltage: Mapped[Optional[int]] = mapped_column(Integer, comment='过压值')
    lvoltage: Mapped[Optional[int]] = mapped_column(Integer, comment='过压值')
    geleflow: Mapped[Optional[int]] = mapped_column(Integer, comment='过流值')
    eleleakage: Mapped[Optional[int]] = mapped_column(Integer, comment='漏电值')
    gtemperature: Mapped[Optional[int]] = mapped_column(Integer, comment='接口过温值')
    gworkrate: Mapped[Optional[int]] = mapped_column(Integer, comment='过载有功功率')
    eleh: Mapped[Optional[int]] = mapped_column(BigInteger, comment='限电度数H')
    elel: Mapped[Optional[int]] = mapped_column(BigInteger, comment='限电度数L')
    clientdata: Mapped[Optional[str]] = mapped_column(String(20), comment='客户数据H')
    lock: Mapped[Optional[str]] = mapped_column(String(20), comment='远程锁扣/解锁')
    control: Mapped[Optional[str]] = mapped_column(String(20), comment='自动控制/手动')
    gate: Mapped[Optional[str]] = mapped_column(String(20), comment='远程合闸/分闸')
    remainder: Mapped[Optional[int]] = mapped_column(Integer, comment='余额限值')
    jumpgate: Mapped[Optional[int]] = mapped_column(Integer, comment='跳闸开关(0,过压;1,欠压;2,过流3,漏电;4,过温;5,过载;6,费用功能开关;7,低余额跳闸开关)')


class ATpFridge(Base):
    __tablename__ = 'a_tp_fridge'
    __table_args__ = (
        PrimaryKeyConstraint('fno', name='a_tp_fridge_pkey'),
        {'schema': 'public'}
    )

    fno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='自增长')
    fupddate: Mapped[datetime.datetime] = mapped_column(TIMESTAMP(precision=6), comment='更新时间')
    blemac: Mapped[str] = mapped_column(String(20), comment='蓝牙mac')
    id: Mapped[Optional[int]] = mapped_column(Integer, comment='record id')
    power: Mapped[Optional[int]] = mapped_column(Integer, comment='power')
    temperature: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='温度')
    humidity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='湿度')
    createtime: Mapped[Optional[int]] = mapped_column(BigInteger, comment='时间戳')


class ATpPoint(Base):
    __tablename__ = 'a_tp_point'
    __table_args__ = (
        PrimaryKeyConstraint('id', 'time', name='a_tp_point_pkey'),
        Index('idx_a_tp_point_id', 'id'),
        Index('idx_a_tp_point_time', 'time'),
        {'comment': '空气狗实时数据', 'schema': 'public'}
    )

    id: Mapped[str] = mapped_column(String(50), primary_key=True, comment='设备ID')
    time: Mapped[datetime.datetime] = mapped_column(DateTime, primary_key=True, comment='采集时间')
    name: Mapped[Optional[str]] = mapped_column(String(50), comment='设备名称')
    lat: Mapped[Optional[str]] = mapped_column(String(10))
    lon: Mapped[Optional[str]] = mapped_column(String(10))
    pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='细颗粒物(PM2.5)')
    pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='可吸入颗粒物(PM10)')
    pm1: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2))
    co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='二氧化碳')
    hcho: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='室内甲醛')
    tvoc: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='室内挥发性有机物')
    co: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2))
    t: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='温度')
    h: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='湿度')
    utc_time: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime)
    org: Mapped[Optional[str]] = mapped_column(String(20))
    area: Mapped[Optional[str]] = mapped_column(String(20))
    type: Mapped[Optional[str]] = mapped_column(String(20), comment='类型')
    odm: Mapped[Optional[str]] = mapped_column(String(20))
    status: Mapped[Optional[str]] = mapped_column(String(10), comment='联网')
    adf_status: Mapped[Optional[int]] = mapped_column(Integer, comment='状态')
    o3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2))
    no2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2))
    so2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2))
    noise: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='噪音')


class ATpWastebox(Base):
    __tablename__ = 'a_tp_wastebox'
    __table_args__ = (
        PrimaryKeyConstraint('fno', name='a_tp_wastebox_pkey'),
        {'schema': 'public'}
    )

    fno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='自增长')
    fupddate: Mapped[datetime.datetime] = mapped_column(TIMESTAMP(precision=6), comment='更新时间')
    tid: Mapped[Optional[str]] = mapped_column(String(24), comment='设备芯片ID（全球唯一不重复），定长24位')
    kg: Mapped[Optional[str]] = mapped_column(String(30), comment='当前重量---单位为千克（Kg）')
    mm: Mapped[Optional[str]] = mapped_column(String(30), comment='当前桶高---单位MM')
    power: Mapped[Optional[str]] = mapped_column(String(30), comment='当前设备电量 ---单位V')
    csq: Mapped[Optional[str]] = mapped_column(String(30), comment='网络信号质量')
    temp: Mapped[Optional[str]] = mapped_column(String(30), comment='温度')
    humidity: Mapped[Optional[str]] = mapped_column(String(30), comment='湿度---单位：%')
    sleept: Mapped[Optional[str]] = mapped_column(String(30), comment='休眠时间 单位·秒')
    gps: Mapped[Optional[str]] = mapped_column(String(30), comment='GPS地理信息')
    imei: Mapped[Optional[str]] = mapped_column(String(30), comment='国际移动设备识别码')
    imsi: Mapped[Optional[str]] = mapped_column(String(30), comment='国际移动用户识别码')
    ccid: Mapped[Optional[str]] = mapped_column(String(30), comment='集成电路卡标识符')
    gmr: Mapped[Optional[str]] = mapped_column(String(30), comment='网络软件版本')
    sys_ver: Mapped[Optional[str]] = mapped_column(String(30), comment='软件版本号')
    time: Mapped[Optional[str]] = mapped_column(String(30), comment='当前时间yyyyMMddHHmmss')
    status: Mapped[Optional[str]] = mapped_column(String(30), comment='设备状态(1:门开启中;0:关闭)')
    statusmsg: Mapped[Optional[str]] = mapped_column(String(30), comment='状态特别说明')
    initiative: Mapped[Optional[str]] = mapped_column(String(30), comment='是否主动上报(1:设备主动上报;0:服务端GetOpenUpMsg消息要求设备上报)')


class ATqPointAiritem(Base):
    __tablename__ = 'a_tq_point_airitem'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_year', 'fmoniter_quarter', 'fpoint_no', 'fitem_name', name='a_tq_point_airitem_pkey'),
        {'comment': '季度空气指标(BOX)', 'schema': 'public'}
    )

    fmoniter_year: Mapped[int] = mapped_column(Integer, primary_key=True, comment='监测年份')
    fmoniter_quarter: Mapped[int] = mapped_column(Integer, primary_key=True, comment='季度')
    fpoint_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    fitem_name: Mapped[str] = mapped_column(String(40), primary_key=True, comment='空气项目')
    fitem_range: Mapped[Optional[str]] = mapped_column(String(20), comment='范围')
    fitem_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='本月平均')
    ftb_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比值')
    ftb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比升降')
    ftb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='同比旗标')
    fhb_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比值')
    fhb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比升级')
    fhb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='环比旗标')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')


class ATqPointAirquality(Base):
    __tablename__ = 'a_tq_point_airquality'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_year', 'fmoniter_quarter', 'fpoint_no', 'faqi_type', name='a_tq_point_airquality_pkey'),
        {'comment': '季度空气质量(站点/区域/市)', 'schema': 'public'}
    )

    fmoniter_year: Mapped[int] = mapped_column(Integer, primary_key=True, comment='监测年份')
    fmoniter_quarter: Mapped[int] = mapped_column(Integer, primary_key=True, comment='季度')
    fpoint_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    faqi_type: Mapped[int] = mapped_column(Integer, primary_key=True, comment='空气质量等级')
    faqi_name: Mapped[Optional[str]] = mapped_column(String(20), comment='空气质量名称')
    faqi_day: Mapped[Optional[int]] = mapped_column(Integer, comment='天数')
    faqi_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='占比')
    ftb_day: Mapped[Optional[int]] = mapped_column(Integer, comment='同比天数')
    ftb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比升降')
    ftb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='同比旗标')
    fhb_day: Mapped[Optional[int]] = mapped_column(Integer, comment='环比天数')
    fhb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比升级')
    fhb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='环比旗标')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')


class ATqPointMoniter(Base):
    __tablename__ = 'a_tq_point_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_year', 'fmoniter_quarter', 'fpoint_no', name='a_tq_point_moniter_pkey'),
        {'comment': '季度监测点数据(平均值)', 'schema': 'public'}
    )

    fmoniter_year: Mapped[int] = mapped_column(Integer, primary_key=True, comment='监测年份')
    fmoniter_quarter: Mapped[int] = mapped_column(Integer, primary_key=True, comment='季度')
    fpoint_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='监测点编号')
    fsite_no: Mapped[Optional[str]] = mapped_column(String(40), comment='所属站点')
    farea_no: Mapped[Optional[str]] = mapped_column(String(40), comment='所属地区')
    fmoniter_so2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化硫(SO2)')
    fmoniter_no2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化氮(NO2)')
    fmoniter_co: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='一氧化碳(CO)')
    fmoniter_o3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)')
    fmoniter_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='细颗粒物(PM2.5)')
    fmoniter_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='可吸入颗粒物(PM10)')
    faqi: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='AQI')
    fcontaminants: Mapped[Optional[str]] = mapped_column(String(80), comment='首页污染物')
    fmoniter_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内二氧化碳(CO2)')
    fmoniter_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内甲醛')
    fmoniter_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内挥发性有机物')
    fwd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内温度')
    fsd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内湿度')
    faqi2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内AQI')
    fcontaminants2: Mapped[Optional[str]] = mapped_column(String(80), comment='室内首要污染物')
    fnewwork: Mapped[Optional[str]] = mapped_column(String(10), comment='是否联网')
    fpoint_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')
    fmoniter_o3_1: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)1个小时平均')
    fmoniter_o3_8: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)8个小时平均')
    fmoniter_2_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比细颗粒物(PM2.5)')
    fmoniter_2_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比可吸入颗粒物(PM10)')
    fmoniter_2_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内二氧化碳(CO2)')
    fmoniter_2_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内甲醛')
    fmoniter_2_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内挥发性有机物')
    fwd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内温度')
    fsd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内湿度')


class ATqSiteAiritem(Base):
    __tablename__ = 'a_tq_site_airitem'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_year', 'fmoniter_quarter', 'fsite_no', 'fitem_name', name='a_tq_site_airitem_pkey'),
        {'comment': '季度空气指标(站点/区域/市)', 'schema': 'public'}
    )

    fmoniter_year: Mapped[int] = mapped_column(Integer, primary_key=True, comment='监测年份')
    fmoniter_quarter: Mapped[int] = mapped_column(Integer, primary_key=True, comment='季度')
    fsite_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    fitem_name: Mapped[str] = mapped_column(String(40), primary_key=True, comment='空气项目')
    fitem_range: Mapped[Optional[str]] = mapped_column(String(20), comment='范围')
    fitem_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='本月平均')
    ftb_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比值')
    ftb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比升降')
    ftb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='同比旗标')
    fhb_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比值')
    fhb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比升级')
    fhb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='环比旗标')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')


class ATqSiteAirquality(Base):
    __tablename__ = 'a_tq_site_airquality'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_year', 'fmoniter_quarter', 'fsite_no', 'faqi_type', name='a_tq_site_airquality_pkey'),
        {'comment': '季度空气质量(站点/区域/市)', 'schema': 'public'}
    )

    fmoniter_year: Mapped[int] = mapped_column(Integer, primary_key=True, comment='监测年份')
    fmoniter_quarter: Mapped[int] = mapped_column(Integer, primary_key=True, comment='季度')
    fsite_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    faqi_type: Mapped[int] = mapped_column(Integer, primary_key=True, comment='空气质量等级')
    faqi_name: Mapped[Optional[str]] = mapped_column(String(20), comment='空气质量名称')
    faqi_day: Mapped[Optional[int]] = mapped_column(Integer, comment='天数')
    faqi_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='占比')
    ftb_day: Mapped[Optional[int]] = mapped_column(Integer, comment='同比天数')
    ftb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比升降')
    ftb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='同比旗标')
    fhb_day: Mapped[Optional[int]] = mapped_column(Integer, comment='环比天数')
    fhb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比升级')
    fhb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='环比旗标')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')


class ATqSiteMoniter(Base):
    __tablename__ = 'a_tq_site_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_year', 'fmoniter_quarter', 'fsite_no', name='a_tq_site_moniter_pkey'),
        {'comment': '季度站点/区域/市 的情况(平均值)', 'schema': 'public'}
    )

    fmoniter_year: Mapped[int] = mapped_column(Integer, primary_key=True, comment='监测年份')
    fmoniter_quarter: Mapped[int] = mapped_column(Integer, primary_key=True, comment='季度')
    fsite_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    fmoniter_so2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化硫(SO2)')
    fmoniter_no2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化氮(NO2)')
    fmoniter_co: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='一氧化碳(CO)')
    fmoniter_o3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)')
    fmoniter_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='细颗粒物(PM2.5)')
    fmoniter_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='可吸入颗粒物(PM10)')
    faqi: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='AQI')
    fcontaminants: Mapped[Optional[str]] = mapped_column(String(80), comment='首要污染物')
    fmoniter_pm26: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内细颗粒物(PM2.5)')
    fmoniter_pm11: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内可吸入颗粒物(PM10)')
    fmoniter_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内二氧化碳(CO2)')
    fmoniter_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内甲醛')
    fmoniter_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内挥发性有机物')
    fwd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内温度')
    fsd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内湿度')
    faqi2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内AQI')
    fcontaminants2: Mapped[Optional[str]] = mapped_column(String(80), comment='室内首要污染物')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')
    fmoniter_o3_1: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)1个小时平均')
    fmoniter_o3_8: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)8个小时平均')
    fmoniter_2_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比细颗粒物(PM2.5)')
    fmoniter_2_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比可吸入颗粒物(PM10)')
    fmoniter_2_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内二氧化碳(CO2)')
    fmoniter_2_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内甲醛')
    fmoniter_2_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内挥发性有机物')
    fwd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内温度')
    fsd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内湿度')


class ATsAirwarring(Base):
    __tablename__ = 'a_ts_airwarring'
    __table_args__ = (
        PrimaryKeyConstraint('fwarringno', name='a_ts_airwarring_pkey'),
        Index('ix_a_ts_airwarring', 'fsite_no', 'fairitem'),
        {'comment': '空气报警设定', 'schema': 'public'}
    )

    fwarringno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='编号')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='市/区/学校')
    fscore_flag: Mapped[int] = mapped_column(Integer, comment='统计范围(1学校/2教室)')
    fairitem: Mapped[int] = mapped_column(Integer, comment='空气项目')
    fbegnum: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='起始值')
    fendnum: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='起讫值')
    fdescribe: Mapped[str] = mapped_column(String(200), comment='报警说明')
    flevelno: Mapped[int] = mapped_column(Integer, comment='风险等级编号')
    fsendmsg: Mapped[int] = mapped_column(Integer, comment='是否发送消息')
    fsendemail: Mapped[int] = mapped_column(Integer, comment='是否发送邮件')
    fstate: Mapped[int] = mapped_column(Integer, comment='设定状态(1正常/0停止)')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')


class ATsAirwarringPoint(Base):
    __tablename__ = 'a_ts_airwarring_point'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='a_ts_airwarring_point_pkey'),
        Index('ix_a_ts_airwarring_point', 'fwarringno', 'fpoint_no'),
        {'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True)
    fwarringno: Mapped[int] = mapped_column(Integer)
    fpoint_no: Mapped[str] = mapped_column(String(20))


class ATsAirwarringSet(Base):
    __tablename__ = 'a_ts_airwarring_set'
    __table_args__ = (
        PrimaryKeyConstraint('fwarringno', 'fpoint_no', 'fairitem', name='a_ts_airwarring_set_pkey'),
        {'schema': 'public'}
    )

    fwarringno: Mapped[int] = mapped_column(Integer, primary_key=True)
    fpoint_no: Mapped[str] = mapped_column(String(20), primary_key=True)
    fairitem: Mapped[int] = mapped_column(Integer, primary_key=True)
    fbegnum: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3))
    fendnum: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3))


class ATsAirwarringUser(Base):
    __tablename__ = 'a_ts_airwarring_user'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='a_ts_airwarring_user_pkey'),
        Index('ix_a_ts_airwarring_user', 'fwarringno', 'fuserno'),
        {'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True)
    fwarringno: Mapped[int] = mapped_column(Integer)
    fuserno: Mapped[str] = mapped_column(String(20))


class ATsHoliday(Base):
    __tablename__ = 'a_ts_holiday'
    __table_args__ = (
        PrimaryKeyConstraint('fholidayid', name='a_ts_holiday_pkey'),
        Index('ix_a_ts_holiday', 'fsite_no', 'fbegdate', 'fenddate'),
        {'comment': '节假日表', 'schema': 'public'}
    )

    fholidayid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='假期编号')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='市/区/学校')
    fholidayname: Mapped[str] = mapped_column(String(80), comment='假期说明')
    fbegdate: Mapped[datetime.datetime] = mapped_column(DateTime, comment='放假开始日期')
    fenddate: Mapped[datetime.datetime] = mapped_column(DateTime, comment='放假结束日期')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    ftype: Mapped[Optional[int]] = mapped_column(Integer, comment='日期类型(1.假期 2.工作日)')


class ATsLayer(Base):
    __tablename__ = 'a_ts_layer'
    __table_args__ = (
        PrimaryKeyConstraint('flayer_no', name='pk_a_ts_layer'),
        {'comment': '楼层数据', 'schema': 'public'}
    )

    flayer_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='楼层编号')
    flayer_name: Mapped[str] = mapped_column(String(48), comment='楼层名称')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='所属站点')
    fpoint_no: Mapped[str] = mapped_column(String(40), comment='所属楼编号')
    fpoint_l: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(20, 10), comment='纬度')
    fpoint_d: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(20, 10), comment='经度')
    fpoint_h: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(20, 10), comment='高度')
    fpoint_w: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(20, 10), comment='宽度')
    fimage: Mapped[Optional[str]] = mapped_column(String(100), comment='平面图')
    fvideo_url: Mapped[Optional[str]] = mapped_column(String(100), comment='视频URL')
    fperson: Mapped[Optional[str]] = mapped_column(String(20), comment='责任人')
    flayer_state: Mapped[Optional[int]] = mapped_column(Integer, comment='状态(1正常/0停用)')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class ATsMoniterDict(Base):
    __tablename__ = 'a_ts_moniter_dict'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='a_ts_moniter_dict_pkey'),
        {'comment': '空气质量分指数', 'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='序号')
    fiaqi: Mapped[Optional[int]] = mapped_column(Integer, comment='空气质量分指数(IAQI)')
    fso2_24: Mapped[Optional[int]] = mapped_column(Integer, comment='二氧化硫(SO2)24小时平均/ug/m3')
    fso2_1: Mapped[Optional[int]] = mapped_column(Integer, comment='二氧化硫(SO2)1小时平均/ug/m3')
    fno2_24: Mapped[Optional[int]] = mapped_column(Integer, comment='二氧化氮(NO2)24小时平均ug/m3')
    fno2_1: Mapped[Optional[int]] = mapped_column(Integer, comment='二氧化氮(NO2)1小时平均ug/m3')
    fpm10_24: Mapped[Optional[int]] = mapped_column(Integer, comment='颗粒物(粒径小于等于10um)24小时平均ug/m3')
    fco_24: Mapped[Optional[int]] = mapped_column(Integer, comment='一氧化碳(CO)24小时平均mg/m3')
    fco_1: Mapped[Optional[int]] = mapped_column(Integer, comment='一氧化碳(CO)1小时平均mg/m3')
    fo3_1: Mapped[Optional[int]] = mapped_column(Integer, comment='臭氧(O3)1小时平均ug/m3')
    fo3_8: Mapped[Optional[int]] = mapped_column(Integer, comment='臭氧(O3)8小时滑动平均ug/m3')
    fpm25_24: Mapped[Optional[int]] = mapped_column(Integer, comment='颗粒物(粒径小于等于2.5um)24小时平均ug/m3')


class ATsPoint(Base):
    __tablename__ = 'a_ts_point'
    __table_args__ = (
        PrimaryKeyConstraint('fpoint_no', name='a_ts_point_pkey'),
        {'comment': '实验楼+实验室', 'schema': 'public'}
    )

    fpoint_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='监测点编号')
    fpoint_name: Mapped[str] = mapped_column(String(48), comment='监测点名称')
    fparent_no: Mapped[str] = mapped_column(String(40), comment='上级监测点')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='所属站点')
    fpoint_flag: Mapped[int] = mapped_column(Integer, comment='站点类型(0:教室,1:室外,2:教学楼)ts_dict.1002')
    fpoint_level: Mapped[Optional[int]] = mapped_column(Integer, comment='楼层')
    fpoint_l: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(20, 10), comment='纬度')
    fpoint_d: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(20, 10), comment='经度')
    fpoint_h: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(20, 10), comment='高度')
    fpoint_w: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(20, 10), comment='宽度')
    fimage: Mapped[Optional[str]] = mapped_column(String(100), comment='平面图')
    fvideo_url: Mapped[Optional[str]] = mapped_column(String(500), comment='视频URL')
    fperson: Mapped[Optional[str]] = mapped_column(String(20), comment='责任人')
    fpoint_state: Mapped[Optional[int]] = mapped_column(Integer, comment='状态(1正常/0停用)')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')
    flayer_no: Mapped[Optional[str]] = mapped_column(String(20))
    fcustnum: Mapped[Optional[int]] = mapped_column(Integer, server_default=text('0'), comment='会议人数')
    fcharge: Mapped[Optional[int]] = mapped_column(Integer, comment='收费方式(1:按次/2:按小时)s_ts_dict.2019')
    fchargeprice: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='收费标准')
    fsize: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='面积')
    fappno: Mapped[Optional[str]] = mapped_column(String(64), comment='平板编号')
    fmjtype: Mapped[Optional[int]] = mapped_column(Integer, comment='门禁类型s_ts_dict.2020')


class ATsSite(Base):
    __tablename__ = 'a_ts_site'
    __table_args__ = (
        PrimaryKeyConstraint('fsite_no', name='a_ts_site_pkey'),
        {'comment': '地区资料', 'schema': 'public'}
    )

    fsite_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='地区编号')
    fsite_name: Mapped[str] = mapped_column(String(48), comment='地区名称')
    fsite_parent: Mapped[str] = mapped_column(String(20), comment='上级地区')
    fsite_level: Mapped[int] = mapped_column(Integer, comment='地区编号(0:省,1:市;2:区,3:学校)ts_dict.1001')
    fsite_state: Mapped[int] = mapped_column(Integer, comment='状态(1正常/0停用)')
    fsite_l: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(20, 10), comment='纬度')
    fsite_d: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(20, 10), comment='经度')
    fengineer: Mapped[Optional[str]] = mapped_column(String(20), comment='工程师')
    fphone: Mapped[Optional[str]] = mapped_column(String(15), comment='手机')
    ftelno: Mapped[Optional[str]] = mapped_column(String(20), comment='电话')
    femail: Mapped[Optional[str]] = mapped_column(String(50), comment='邮箱')
    fimage: Mapped[Optional[str]] = mapped_column(String(100), comment='平面图')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')
    fso2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='当前二氧化硫值')
    fno2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='当前二氧化氮值')
    fco: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='当前一氧化碳值')
    fo3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='当前臭氧值')
    fpm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='当前PM2.5值')
    fpm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='当前PM10值')
    fwd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室外温度')
    fsd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室外温度')
    noise: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 0), comment='噪音')
    faqi: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='当前AQI值')
    faqi_tb: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='同比AQI值')
    faqi_hb: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='环比AQI值')
    fcontaminants: Mapped[Optional[str]] = mapped_column(String(80), comment='首要污染物')
    fpm26: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内PM2.5值')
    fpm11: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内PM10值')
    fco2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内二氧化碳(CO2)')
    fjq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内甲醛')
    fyjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内挥发性有机物')
    fwd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内温度')
    fsd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内湿度')
    faqi2: Mapped[Optional[str]] = mapped_column(String(20), comment='室内AQI')
    fcontaminants2: Mapped[Optional[str]] = mapped_column(String(80), comment='室内首要污染物')
    fnetwork_ok: Mapped[Optional[int]] = mapped_column(Integer, comment='联网成功数')
    fnetwork_no: Mapped[Optional[int]] = mapped_column(Integer, comment='断网成功数')
    frefresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新时间')
    fsite_type: Mapped[Optional[int]] = mapped_column(Integer, comment='客户行业(教育/零售)')
    day_off: Mapped[Optional[str]] = mapped_column(String(20), comment='休息日(1,2,3,4,5,6,7)')
    fbegtime: Mapped[Optional[str]] = mapped_column(String(5), comment='上班时间')
    fendtime: Mapped[Optional[str]] = mapped_column(String(5), comment='下班时间')
    fimage3d: Mapped[Optional[str]] = mapped_column(String(100), comment='3D图')
    fboxflag: Mapped[Optional[int]] = mapped_column(Integer, server_default=text('0'), comment='柜子授权')
    fuseflag: Mapped[Optional[int]] = mapped_column(Integer, server_default=text('0'), comment='预约授权')
    flink_man: Mapped[Optional[str]] = mapped_column(String(20), comment='联系人')
    fusetype: Mapped[Optional[int]] = mapped_column(Integer, server_default=text('0'), comment='物料预约')
    finvtype: Mapped[Optional[int]] = mapped_column(Integer, server_default=text('0'), comment='盘点预约')
    fouttype: Mapped[Optional[int]] = mapped_column(Integer, server_default=text('0'), comment='出库预约')
    fapiflag: Mapped[Optional[int]] = mapped_column(Integer, server_default=text('0'), comment='启用课程表')
    fcourseflag: Mapped[Optional[int]] = mapped_column(Integer, server_default=text('0'), comment='是否开启课程')
    fbegindate: Mapped[Optional[datetime.date]] = mapped_column(Date, comment='授权开始日期')
    fenddate: Mapped[Optional[datetime.date]] = mapped_column(Date, comment='授权结束日期')
    fcharge: Mapped[Optional[int]] = mapped_column(Integer, comment='收费方式(1:按次/2:按小时)s_ts_dict.2019')
    fchargeprice: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='收费标准')
    fappurl: Mapped[Optional[str]] = mapped_column(String(100), comment='门禁URL')
    fappid: Mapped[Optional[str]] = mapped_column(String(20), comment='门禁APPID')
    fappkey: Mapped[Optional[str]] = mapped_column(String(64), comment='门禁APPKEY')
    fappsecret: Mapped[Optional[str]] = mapped_column(String(64), comment='门禁AppSecret')


class ATtPointMoniter(Base):
    __tablename__ = 'a_tt_point_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fpoint_no', 'fmoniter_date', name='a_tt_point_moniter_pkey'),
        {'schema': 'public'}
    )

    fpoint_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='监测点')
    fmoniter_date: Mapped[datetime.datetime] = mapped_column(DateTime, primary_key=True, comment='监测日期')
    fmoniter_so2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化硫(SO2)')
    fmoniter_no2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化氮(NO2)')
    fmoniter_co: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='一氧化碳(CO)')
    fmoniter_o3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)')
    fmoniter_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='细颗粒物(PM2.5)')
    fmoniter_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='可吸入颗粒物(PM10)')
    faqi: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='AQI')
    fcontaminants: Mapped[Optional[str]] = mapped_column(String(80), comment='首要污染物')
    fmoniter_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内二氧化碳(CO2)')
    fmoniter_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内甲醛')
    fmoniter_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内挥发性有机物')
    fwd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内温度')
    fsd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内湿度')
    faqi2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内AQI')
    fcontaminants2: Mapped[Optional[str]] = mapped_column(String(80), comment='室内首要污染物')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')
    fmacno: Mapped[Optional[str]] = mapped_column(String(20))


class ATyPointAiritem(Base):
    __tablename__ = 'a_ty_point_airitem'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_year', 'fpoint_no', 'fitem_name', name='a_ty_point_airitem_pkey'),
        {'comment': '年度空气指标(室外BOX)', 'schema': 'public'}
    )

    fmoniter_year: Mapped[int] = mapped_column(Integer, primary_key=True, comment='监测年份')
    fpoint_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    fitem_name: Mapped[str] = mapped_column(String(40), primary_key=True, comment='空气项目')
    fitem_range: Mapped[Optional[str]] = mapped_column(String(20), comment='范围')
    fitem_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='本月平均')
    ftb_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比值')
    ftb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比升降')
    ftb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='同比旗标')
    fhb_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比值')
    fhb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比升级')
    fhb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='环比旗标')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')


class ATyPointAirquality(Base):
    __tablename__ = 'a_ty_point_airquality'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_year', 'fpoint_no', 'faqi_type', name='a_ty_point_airquality_pkey'),
        {'comment': '年度空气质量(站点/区域/市)', 'schema': 'public'}
    )

    fmoniter_year: Mapped[int] = mapped_column(Integer, primary_key=True, comment='监测年份')
    fpoint_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    faqi_type: Mapped[int] = mapped_column(Integer, primary_key=True, comment='空气质量等级')
    faqi_name: Mapped[Optional[str]] = mapped_column(String(20), comment='空气质量名称')
    faqi_day: Mapped[Optional[int]] = mapped_column(Integer, comment='天数')
    faqi_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='占比')
    ftb_day: Mapped[Optional[int]] = mapped_column(Integer, comment='同比天数')
    ftb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比升降')
    ftb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='同比旗标')
    fhb_day: Mapped[Optional[int]] = mapped_column(Integer, comment='环比天数')
    fhb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比升级')
    fhb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='环比旗标')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')


class ATyPointMoniter(Base):
    __tablename__ = 'a_ty_point_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_year', 'fpoint_no', name='a_ty_point_moniter_pkey'),
        {'comment': '年监测点数据(平均值)', 'schema': 'public'}
    )

    fmoniter_year: Mapped[int] = mapped_column(Integer, primary_key=True, comment='监测年份')
    fpoint_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='监测点编号')
    fsite_no: Mapped[Optional[str]] = mapped_column(String(40), comment='所属站点')
    farea_no: Mapped[Optional[str]] = mapped_column(String(40), comment='所属地区')
    fmoniter_so2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化硫(SO2)')
    fmoniter_no2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化氮(NO2)')
    fmoniter_co: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='一氧化碳(CO)')
    fmoniter_o3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)')
    fmoniter_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='细颗粒物(PM2.5)')
    fmoniter_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='可吸入颗粒物(PM10)')
    faqi: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='AQI')
    fcontaminants: Mapped[Optional[str]] = mapped_column(String(80), comment='首页污染物')
    fmoniter_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内二氧化碳(CO2)')
    fmoniter_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内甲醛')
    fmoniter_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内挥发性有机物')
    fwd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内温度')
    fsd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内湿度')
    faqi2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内AQI')
    fcontaminants2: Mapped[Optional[str]] = mapped_column(String(80), comment='室内首要污染物')
    fnewwork: Mapped[Optional[str]] = mapped_column(String(10), comment='是否联网')
    fpoint_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')
    fmoniter_o3_1: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)1个小时平均')
    fmoniter_o3_8: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)8个小时平均')
    fmoniter_2_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比细颗粒物(PM2.5)')
    fmoniter_2_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比可吸入颗粒物(PM10)')
    fmoniter_2_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内二氧化碳(CO2)')
    fmoniter_2_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内甲醛')
    fmoniter_2_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内挥发性有机物')
    fwd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内温度')
    fsd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内湿度')


class ATySiteAiritem(Base):
    __tablename__ = 'a_ty_site_airitem'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_year', 'fsite_no', 'fitem_name', name='a_ty_site_airitem_pkey'),
        {'comment': '年度空气指标(站点/区域/市)', 'schema': 'public'}
    )

    fmoniter_year: Mapped[int] = mapped_column(Integer, primary_key=True, comment='监测年份')
    fsite_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    fitem_name: Mapped[str] = mapped_column(String(40), primary_key=True, comment='空气项目')
    fitem_range: Mapped[Optional[str]] = mapped_column(String(20), comment='范围')
    fitem_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='本月平均')
    ftb_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比值')
    ftb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比升降')
    ftb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='同比旗标')
    fhb_value: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比值')
    fhb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比升级')
    fhb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='环比旗标')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')


class ATySiteAirquality(Base):
    __tablename__ = 'a_ty_site_airquality'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_year', 'fsite_no', 'faqi_type', name='a_ty_site_airquality_pkey'),
        {'comment': '年度空气质量(站点/区域/市)', 'schema': 'public'}
    )

    fmoniter_year: Mapped[int] = mapped_column(Integer, primary_key=True, comment='监测年份')
    fsite_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    faqi_type: Mapped[int] = mapped_column(Integer, primary_key=True, comment='空气质量等级')
    faqi_name: Mapped[Optional[str]] = mapped_column(String(20), comment='空气质量名称')
    faqi_day: Mapped[Optional[int]] = mapped_column(Integer, comment='天数')
    faqi_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='占比')
    ftb_day: Mapped[Optional[int]] = mapped_column(Integer, comment='同比天数')
    ftb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比升降')
    ftb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='同比旗标')
    fhb_day: Mapped[Optional[int]] = mapped_column(Integer, comment='环比天数')
    fhb_rate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='环比升级')
    fhb_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='环比旗标')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')


class ATySiteMoniter(Base):
    __tablename__ = 'a_ty_site_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_year', 'fsite_no', name='a_ty_site_moniter_pkey'),
        {'comment': '年站点/区域/市 的情况(平均值)', 'schema': 'public'}
    )

    fmoniter_year: Mapped[int] = mapped_column(Integer, primary_key=True, comment='监测年份')
    fsite_no: Mapped[str] = mapped_column(String(40), primary_key=True, comment='地区编号')
    fmoniter_so2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化硫(SO2)')
    fmoniter_no2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='二氧化氮(NO2)')
    fmoniter_co: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='一氧化碳(CO)')
    fmoniter_o3: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)')
    fmoniter_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='细颗粒物(PM2.5)')
    fmoniter_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='可吸入颗粒物(PM10)')
    faqi: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='AQI')
    fcontaminants: Mapped[Optional[str]] = mapped_column(String(80), comment='首要污染物')
    fmoniter_pm26: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内细颗粒物(PM2.5)')
    fmoniter_pm11: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内可吸入颗粒物(PM10)')
    fmoniter_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内二氧化碳(CO2)')
    fmoniter_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内甲醛')
    fmoniter_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内挥发性有机物')
    fwd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内温度')
    fsd: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内湿度')
    faqi2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='室内AQI')
    fcontaminants2: Mapped[Optional[str]] = mapped_column(String(80), comment='室内首要污染物')
    fsite_refresh: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='刷新日期')
    fmoniter_o3_1: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)1个小时平均')
    fmoniter_o3_8: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='臭氧(O3)8个小时平均')
    fmoniter_2_pm25: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比细颗粒物(PM2.5)')
    fmoniter_2_pm10: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比可吸入颗粒物(PM10)')
    fmoniter_2_co2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内二氧化碳(CO2)')
    fmoniter_2_jq: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内甲醛')
    fmoniter_2_yjw: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内挥发性有机物')
    fwd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内温度')
    fsd2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='同比室内湿度')


class AmAd(Base):
    __tablename__ = 'am_ad'
    __table_args__ = (
        PrimaryKeyConstraint('fid', name='am_ad_pkey'),
        {'schema': 'public'}
    )

    fid: Mapped[int] = mapped_column(Integer, primary_key=True)
    fpicurl: Mapped[str] = mapped_column(String(255), comment='广告图片')
    fposition: Mapped[int] = mapped_column(SmallInteger, comment='广告图片顺序位置')
    enabled: Mapped[int] = mapped_column(SmallInteger, comment='启用状态')
    fname: Mapped[Optional[str]] = mapped_column(String(100), comment='广告标题')
    flink: Mapped[Optional[str]] = mapped_column(String(255), comment='广告链接地址')
    fcontent: Mapped[Optional[str]] = mapped_column(String(255), comment='广告描述')
    fstarttime: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='开始时间')
    fendtime: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='结束时间')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class AmSysAdminLog(Base):
    __tablename__ = 'am_sys_admin_log'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='am_sys_admin_log_pkey'),
        {'comment': '后台日志表', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment='编号')
    user_id: Mapped[Optional[int]] = mapped_column(BigInteger, comment='用户编号')
    user_name: Mapped[Optional[str]] = mapped_column(String(55), comment='用户名')
    service_name: Mapped[Optional[str]] = mapped_column(String(100), comment='模块名')
    method: Mapped[Optional[str]] = mapped_column(String(255), comment='记录类名+方法名')
    operation_desc: Mapped[Optional[str]] = mapped_column(String(255), comment='描述')
    create_time: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='创建时间')
    ip: Mapped[Optional[str]] = mapped_column(String(100), comment='IP')
    params: Mapped[Optional[str]] = mapped_column(String(3000), comment='参数')


class AmSysApiLog(Base):
    __tablename__ = 'am_sys_api_log'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='am_sys_api_log_pkey'),
        Index('ix_am_sys_api_log', 'create_time', 'user_id'),
        {'comment': 'API访问日志', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment='编号')
    create_time: Mapped[datetime.datetime] = mapped_column(DateTime, comment='访问时间')
    method: Mapped[str] = mapped_column(String(255), comment='记录类名+方法名')
    user_id: Mapped[int] = mapped_column(BigInteger, comment='用户编号')
    ip: Mapped[Optional[str]] = mapped_column(String(100), comment='访问IP')
    service_name: Mapped[Optional[str]] = mapped_column(String(100), comment='模块名')
    user_name: Mapped[Optional[str]] = mapped_column(String(50), comment='用户名')
    operation_desc: Mapped[Optional[str]] = mapped_column(String(100), comment='描述')
    params: Mapped[Optional[str]] = mapped_column(String(50), comment='token')


class AmSysDepart(Base):
    __tablename__ = 'am_sys_depart'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='am_sys_depart_pkey'),
        Index('index_depart_depart_order', 'depart_order'),
        Index('index_depart_org_code', 'org_code'),
        Index('index_depart_parent_id', 'parent_id'),
        {'comment': '组织机构表', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment='ID')
    depart_name: Mapped[str] = mapped_column(String(100), comment='机构/部门名称')
    org_code: Mapped[str] = mapped_column(String(64), comment='机构编码')
    parent_id: Mapped[Optional[str]] = mapped_column(String(32), comment='父机构ID')
    depart_name_en: Mapped[Optional[str]] = mapped_column(String(500), comment='英文名')
    depart_name_abbr: Mapped[Optional[str]] = mapped_column(String(500), comment='缩写')
    depart_order: Mapped[Optional[int]] = mapped_column(Integer, comment='排序')
    description: Mapped[Optional[str]] = mapped_column(Text, comment='描述')
    org_type: Mapped[Optional[str]] = mapped_column(String(10), comment='机构类型')
    mobile: Mapped[Optional[str]] = mapped_column(String(32), comment='手机号')
    fax: Mapped[Optional[str]] = mapped_column(String(32), comment='传真')
    address: Mapped[Optional[str]] = mapped_column(String(100), comment='地址')
    memo: Mapped[Optional[str]] = mapped_column(String(500), comment='备注')
    status: Mapped[Optional[str]] = mapped_column(String(1), comment='状态（1启用，0不启用）')
    del_flag: Mapped[Optional[str]] = mapped_column(String(1), comment='删除状态（0，正常，1已删除）')
    create_by: Mapped[Optional[str]] = mapped_column(String(32), comment='创建人')
    create_time: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='创建日期')
    update_by: Mapped[Optional[str]] = mapped_column(String(32), comment='更新人')
    update_time: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='更新日期')


class AmSysMenu(Base):
    __tablename__ = 'am_sys_menu'
    __table_args__ = (
        PrimaryKeyConstraint('menu_id', name='pk_am_sys_menu'),
        {'comment': '系统菜单表', 'schema': 'public'}
    )

    menu_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment='当前菜单 ID')
    title: Mapped[str] = mapped_column(String(20), comment='菜单名称')
    type: Mapped[int] = mapped_column(SmallInteger, comment='菜单类型，0 表示目录，1 表示菜单项，2 表示按钮')
    parent_id: Mapped[Optional[int]] = mapped_column(BigInteger, comment='当前菜单父菜单 ID')
    path: Mapped[Optional[str]] = mapped_column(String(100), comment='路径')
    icon: Mapped[Optional[str]] = mapped_column(String(100), comment='菜单图标')
    delete_flag: Mapped[Optional[int]] = mapped_column(SmallInteger, comment='逻辑删除标志，0 表示未删除， 1 表示删除')
    visible_flag: Mapped[Optional[int]] = mapped_column(SmallInteger, comment='是否可见')
    order_num: Mapped[Optional[int]] = mapped_column(Integer, comment='菜单项顺序')
    create_time: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='创建时间')
    update_time: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')


class AmSysPermission(Base):
    __tablename__ = 'am_sys_permission'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='am_sys_permission_pkey'),
        {'comment': '后台用户权限表', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
    pid: Mapped[Optional[int]] = mapped_column(BigInteger, comment='父级权限id')
    name: Mapped[Optional[str]] = mapped_column(String(100), comment='名称')
    value: Mapped[Optional[str]] = mapped_column(String(200), comment='权限值')
    icon: Mapped[Optional[str]] = mapped_column(Text, comment='图标')
    type: Mapped[Optional[int]] = mapped_column(Integer, comment='权限类型：0->目录；1->菜单；2->按钮（接口绑定权限）')
    uri: Mapped[Optional[str]] = mapped_column(String(200), comment='前端资源路径')
    status: Mapped[Optional[int]] = mapped_column(Integer, comment='启用状态；0->禁用；1->启用')
    create_time: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='创建时间')
    sort_seq: Mapped[Optional[int]] = mapped_column(Integer, comment='排序')
    method: Mapped[Optional[str]] = mapped_column(String(10))
    create_id: Mapped[Optional[int]] = mapped_column(BigInteger)
    update_time: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6))
    update_id: Mapped[Optional[int]] = mapped_column(BigInteger)
    fname: Mapped[Optional[str]] = mapped_column(String(100), comment='繁体名称')
    yname: Mapped[Optional[str]] = mapped_column(String(100), comment='英文名称')
    systype: Mapped[Optional[str]] = mapped_column(String(20), comment='菜单所属系统 S 食品安全 I 物联网  L 实验室')


class AmSysPermissionbutton(Base):
    __tablename__ = 'am_sys_permissionbutton'
    __table_args__ = (
        PrimaryKeyConstraint('id', 'buttonid', name='am_sys_permissionbutton_pkey'),
        {'comment': '功能菜单按钮', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment='菜单编号')
    buttonid: Mapped[str] = mapped_column(String(20), primary_key=True, comment='按钮编号')
    buttonname: Mapped[str] = mapped_column(String(20), comment='按钮名称')


class AmSysRole(Base):
    __tablename__ = 'am_sys_role'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='am_sys_role_pkey'),
        {'comment': '后台用户角色表', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
    name: Mapped[Optional[str]] = mapped_column(String(100), comment='名称')
    description: Mapped[Optional[str]] = mapped_column(String(500), comment='描述')
    user_count: Mapped[Optional[int]] = mapped_column(Integer, comment='后台用户数量')
    create_time: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='创建时间')
    status: Mapped[Optional[int]] = mapped_column(Integer, comment='启用状态：0->禁用；1->启用')
    sort_seq: Mapped[Optional[int]] = mapped_column(Integer)
    create_id: Mapped[Optional[int]] = mapped_column(BigInteger)
    update_time: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6))
    update_id: Mapped[Optional[int]] = mapped_column(BigInteger)


class AmSysRoleButton(Base):
    __tablename__ = 'am_sys_role_button'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='am_sys_role_button_pkey'),
        Index('ix_am_sys_role_button', 'role_id', 'permission_id'),
        {'comment': '角色按钮权限', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment='自增长')
    role_id: Mapped[Optional[int]] = mapped_column(BigInteger, comment='角色编号')
    permission_id: Mapped[Optional[int]] = mapped_column(BigInteger, comment='菜单编号')
    buttonid: Mapped[Optional[str]] = mapped_column(String(20), comment='按钮名称')


class AmSysRoleMenu(Base):
    __tablename__ = 'am_sys_role_menu'
    __table_args__ = (
        PrimaryKeyConstraint('role_id', 'menu_id', name='pk_am_sys_role_menu'),
        {'comment': '系统角色菜单表', 'schema': 'public'}
    )

    role_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment='角色ID')
    menu_id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment='菜单 ID')


class AmSysRolePermission(Base):
    __tablename__ = 'am_sys_role_permission'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='am_sys_role_permission_pkey'),
        {'comment': '后台用户角色和权限关系表', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
    role_id: Mapped[Optional[int]] = mapped_column(BigInteger)
    permission_id: Mapped[Optional[int]] = mapped_column(BigInteger)


class AmSysSqlLog(Base):
    __tablename__ = 'am_sys_sql_log'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='am_sys_sql_log_pkey'),
        Index('ix_am_sys_sql_log', 'create_time', 'datatype'),
        {'comment': '系统日志', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment='编号')
    create_time: Mapped[datetime.datetime] = mapped_column(DateTime, comment='记录时间')
    datatype: Mapped[int] = mapped_column(BigInteger, comment='业务编号')
    dataname: Mapped[str] = mapped_column(String(60), comment='业务名称')
    dataflag: Mapped[int] = mapped_column(BigInteger, comment='日志旗标(1成功0报错)')
    msg: Mapped[str] = mapped_column(String(500), comment='日志信息')


class AmSysUser(Base):
    __tablename__ = 'am_sys_user'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='am_sys_user_pkey'),
        Index('idx_user_phone', 'phone'),
        Index('idx_user_username', 'username'),
        {'comment': '后台用户表', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
    username: Mapped[Optional[str]] = mapped_column(String(64), comment='用户名(登录用)')
    password: Mapped[Optional[str]] = mapped_column(String(64), comment='密码')
    icon: Mapped[Optional[str]] = mapped_column(String(500), comment='头像')
    email: Mapped[Optional[str]] = mapped_column(String(100), comment='邮箱')
    nick_name: Mapped[Optional[str]] = mapped_column(String(200), comment='昵称')
    note: Mapped[Optional[str]] = mapped_column(String(500), comment='备注信息')
    create_time: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='创建时间')
    login_time: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='最后登录时间')
    status: Mapped[Optional[int]] = mapped_column(Integer, comment='帐号启用状态：0->禁用；1->启用')
    phone: Mapped[Optional[str]] = mapped_column(String(20), comment='手机号(登录用)')
    create_id: Mapped[Optional[int]] = mapped_column(BigInteger, comment='创建用户')
    update_time: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='更新时间')
    update_id: Mapped[Optional[int]] = mapped_column(BigInteger, comment='更新用户')
    fsite_no_belong: Mapped[Optional[str]] = mapped_column(String(20), comment='所属地区')
    ftype: Mapped[Optional[int]] = mapped_column(Integer, comment='用户类型(2前端，1后端，3都是)')
    fpoint_noes: Mapped[Optional[str]] = mapped_column(String(255), comment='教学楼编号')
    fcard: Mapped[Optional[str]] = mapped_column(String(20), comment='用户卡号')
    password_clear: Mapped[Optional[str]] = mapped_column(String(64), comment='明文密码')
    fappno: Mapped[Optional[str]] = mapped_column(String(64), comment='平板编号')
    enterprise_wechat: Mapped[Optional[str]] = mapped_column(String(100), comment='企业微信')


class AmSysUserDetail(Base):
    __tablename__ = 'am_sys_user_detail'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='am_sys_user_detail_pkey'),
        UniqueConstraint('user_id', name='user_id_only'),
        {'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True)
    user_id: Mapped[Optional[int]] = mapped_column(BigInteger)
    enterprise_wechat: Mapped[Optional[str]] = mapped_column(String(255), comment='企业微信用户名')


class AmSysUserPermission(Base):
    __tablename__ = 'am_sys_user_permission'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='am_sys_user_permission_pkey'),
        {'comment': '后台用户和权限关系表(除角色中定义的权限以外的加减权限)', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
    user_id: Mapped[Optional[int]] = mapped_column(BigInteger)
    permission_id: Mapped[Optional[int]] = mapped_column(BigInteger)
    type: Mapped[Optional[int]] = mapped_column(Integer)


class AmSysUserPoint(Base):
    __tablename__ = 'am_sys_user_point'
    __table_args__ = (
        PrimaryKeyConstraint('fno', name='am_sys_user_point_pkey'),
        {'schema': 'public'}
    )

    fno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='自增id')
    fid: Mapped[int] = mapped_column(BigInteger, comment='用户id')
    fpoint_no: Mapped[str] = mapped_column(String(20), comment='教室编号')


class AmSysUserRole(Base):
    __tablename__ = 'am_sys_user_role'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='am_sys_user_role_pkey'),
        {'comment': '后台用户和角色关系表', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
    user_id: Mapped[Optional[int]] = mapped_column(BigInteger)
    role_id: Mapped[Optional[int]] = mapped_column(BigInteger)


class AmSysWebLog(Base):
    __tablename__ = 'am_sys_web_log'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='am_sys_web_log_pkey'),
        Index('ix_am_sys_web_log', 'create_time', 'ip', 'user_id'),
        {'comment': '操作日志', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, comment='编号')
    create_time: Mapped[datetime.datetime] = mapped_column(DateTime, comment='访问时间')
    method: Mapped[str] = mapped_column(String(255), comment='记录类名+方法名')
    user_id: Mapped[int] = mapped_column(BigInteger, comment='用户编号')
    ip: Mapped[Optional[str]] = mapped_column(String(100), comment='访问IP')
    service_name: Mapped[Optional[str]] = mapped_column(String(100), comment='模块名')
    user_name: Mapped[Optional[str]] = mapped_column(String(50), comment='用户名')
    operation_desc: Mapped[Optional[str]] = mapped_column(String(100), comment='描述')
    params: Mapped[Optional[str]] = mapped_column(String(50), comment='参数')


class AppUpdate(Base):
    __tablename__ = 'app_update'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='app_update_pkey'),
        {'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True)
    fappId: Mapped[str] = mapped_column(String(10), comment='APP类别(01：空气，02：SMART，03：维护)')
    verson: Mapped[Optional[str]] = mapped_column(String(50), comment='版本号')
    updateInfo: Mapped[Optional[str]] = mapped_column(String(200), comment='说明')
    androidLink: Mapped[Optional[str]] = mapped_column(String(200), comment='安卓更新路径')
    iosLink: Mapped[Optional[str]] = mapped_column(String(200), comment='苹果更新路径')
    fstatus: Mapped[Optional[int]] = mapped_column(Integer, comment='状态(0:未发布,1:已发布)')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作者')


class DahuaDoorFace(Base):
    __tablename__ = 'dahua_door_face'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='dahua_door_face_pkey'),
        Index('ix_dahua_door_face', 'stutime', 'derviceip'),
        {'comment': '大华门禁表', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, Sequence('dahua_keep_out_alarm_id_seq', schema='public'), primary_key=True)
    stutime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='事件时间')
    derviceip: Mapped[Optional[str]] = mapped_column(String(100), comment='设备IP')
    uctime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='设备触发时间')
    openstatus: Mapped[Optional[str]] = mapped_column(String(50), comment='开门状态 0.失败 1.成功')
    openmethod: Mapped[Optional[str]] = mapped_column(String(80), comment='开门方式')
    cardno: Mapped[Optional[str]] = mapped_column(String(20), comment='卡号')
    userid: Mapped[Optional[str]] = mapped_column(String(20), comment='用户id')
    cardname: Mapped[Optional[str]] = mapped_column(String(20), comment='卡名')
    mac: Mapped[Optional[str]] = mapped_column(String(64), comment='设备mac(设备主动注册子id，也可以是设备资产码，现在选择mac)')
    phone_url: Mapped[Optional[str]] = mapped_column(String(180), comment='刷脸图片')


class DahuaDoorFaceCard(Base):
    __tablename__ = 'dahua_door_face_card'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='dahua_door_face_card_pkey'),
        Index('id', 'id'),
        {'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True, comment='序号')
    device_no: Mapped[Optional[str]] = mapped_column(String(32), comment='设备')
    card_no: Mapped[Optional[str]] = mapped_column(String(32), comment='卡号')
    user_id: Mapped[Optional[str]] = mapped_column(String(32), comment='用户id')
    card_name: Mapped[Optional[str]] = mapped_column(String(32), comment='卡名')
    card_passwd: Mapped[Optional[str]] = mapped_column(String(32), comment='卡密码')
    card_status: Mapped[Optional[int]] = mapped_column(Integer, comment='卡状态[-1:未知|0:正常|1:挂失|2:注销|3:冻结|4:欠费|5:逾期|6:预欠费]')
    card_status_name: Mapped[Optional[str]] = mapped_column(String(32), comment='卡状态名称')
    card_type: Mapped[Optional[int]] = mapped_column(Integer, comment='卡类型[-1:未知|0:一般卡|1:VIP卡|2:来宾卡|3:巡逻卡|4:黑名单卡|5:胁迫卡|6:巡检卡|7:母卡]')
    card_type_name: Mapped[Optional[str]] = mapped_column(String(32), comment='卡类型名称')
    use_times: Mapped[Optional[str]] = mapped_column(String(32), comment='使用次数，仅当卡类型为来宾卡时有效')
    first_enter: Mapped[Optional[int]] = mapped_column(Integer, comment='是否首卡[0:不是|1:是]')
    enable: Mapped[Optional[int]] = mapped_column(Integer, comment='是否有效[0:不是|1:是]')
    start_time: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='有效期开始时间')
    end_time: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='有效期结束时间')
    record_no: Mapped[Optional[int]] = mapped_column(Integer, comment='记录集编号， 修改、删除卡信息必须填写')
    face_url: Mapped[Optional[str]] = mapped_column(String(128), comment='人脸照片URL')


class DahuaKeepOutAlarm(Base):
    __tablename__ = 'dahua_keep_out_alarm'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='dahua_keep_out_alarm_pkey'),
        Index('ix_dahua_keep_out_alarm', 'stutime', 'derviceip'),
        {'comment': '大华报警表', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
    stutime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='发送时间')
    derviceip: Mapped[Optional[str]] = mapped_column(String(100), comment='设备ip')
    state: Mapped[Optional[int]] = mapped_column(SmallInteger, comment='事件状态： 1-持续性事件开始  0-事件结束')
    alarm: Mapped[Optional[str]] = mapped_column(String(255), comment='警报信息')
    mac: Mapped[Optional[str]] = mapped_column(String(50))


class DahuaPersonnelflow(Base):
    __tablename__ = 'dahua_personnelflow'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='dahua_personnelflow_pkey'),
        Index('ix_dahua_personnelflow', 'stutime', 'derviceip'),
        {'comment': '大华人流量统计表', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
    stutime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='事件时间')
    derviceip: Mapped[Optional[str]] = mapped_column(String(100), comment='设备ip')
    entotal: Mapped[Optional[int]] = mapped_column(Integer, comment='TotalIn:总共进入人数')
    enhour: Mapped[Optional[int]] = mapped_column(Integer, comment='OSD进:本小时进入人数')
    entoday: Mapped[Optional[int]] = mapped_column(Integer, comment='TodayIn:今日进入人数')
    extotal: Mapped[Optional[int]] = mapped_column(Integer, comment='TotalOut:总共离开人数')
    exhour: Mapped[Optional[int]] = mapped_column(Integer, comment='OSD出:本小时离开人数')
    extoday: Mapped[Optional[int]] = mapped_column(Integer, comment='TodayOut:今日离开人数')
    mac: Mapped[Optional[str]] = mapped_column(String(64))


class GsTest(Base):
    __tablename__ = 'gs_test'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='gs_test_pkey'),
        {'comment': '测试专用，字段随便改', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
    tel_number: Mapped[Optional[int]] = mapped_column(BigInteger, server_default=text('0'))
    name: Mapped[Optional[str]] = mapped_column(String(20))
    age: Mapped[Optional[int]] = mapped_column(BigInteger, server_default=text('0'))
    is_delete: Mapped[Optional[bool]] = mapped_column(Boolean, server_default=text('false'))


class Meeting(Base):
    __tablename__ = 'meeting'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='pk_meeting'),
        Index('ix_meeting', 'fsite_no', 'ftaskno', 'speaker', 'room_id', 'begintime', 'meeting_type'),
        {'comment': '实验室预约', 'schema': 'public'}
    )

    id: Mapped[str] = mapped_column(String(64), primary_key=True, comment='会议id')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='客户编号')
    ftaskno: Mapped[str] = mapped_column(String(20), comment='课题组编号')
    speaker: Mapped[str] = mapped_column(String(32), comment='主持人')
    room_id: Mapped[str] = mapped_column(String(64), comment='房间Id(同pointno)')
    begintime: Mapped[datetime.datetime] = mapped_column(DateTime, comment='开始时间')
    endtime: Mapped[datetime.datetime] = mapped_column(DateTime, comment='结束时间')
    checked_state: Mapped[int] = mapped_column(Integer, comment='审核状态，0未审核，1通过，2驳回')
    meeting_type: Mapped[int] = mapped_column(Integer, comment='会议状态，0未开始，1进行中，2已取消,3已结束')
    room_name: Mapped[Optional[str]] = mapped_column(String(32), comment='房间名')
    speaker_id: Mapped[Optional[str]] = mapped_column(String(64), comment='主持人id(会议平台用户id)')
    subject: Mapped[Optional[str]] = mapped_column(String(64), comment='会议主题')
    address: Mapped[Optional[str]] = mapped_column(String(64), comment='地址')
    created_id: Mapped[Optional[str]] = mapped_column(String(64), comment='创建人id')
    createdtime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='创建时间')
    lastupdatetime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='最后更新时间')
    checkedtime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='审核时间')
    memo: Mapped[Optional[str]] = mapped_column(String(200), comment='备注')
    meeting_begin_scene: Mapped[Optional[int]] = mapped_column(BigInteger, comment='会议开始场景编号')
    meeting_end_scene: Mapped[Optional[int]] = mapped_column(BigInteger, comment='会议结束场景编号')
    begin_scene_status: Mapped[Optional[int]] = mapped_column(SmallInteger, comment='开始场景执行状态')
    end_scene_status: Mapped[Optional[int]] = mapped_column(SmallInteger, comment='结束场景执行状态')
    user_name: Mapped[Optional[str]] = mapped_column(String(64), comment='平台用户id')
    signed_number: Mapped[Optional[int]] = mapped_column(Integer, comment='签到人数')
    reason: Mapped[Optional[str]] = mapped_column(String(100), comment='驳回说明')


t_p_cnt = Table(
    'p_cnt', Base.metadata,
    Column('f2', Numeric(12, 4)),
    schema='public'
)


t_p_i = Table(
    'p_i', Base.metadata,
    Column('count', BigInteger),
    schema='public'
)


t_p_site_level = Table(
    'p_site_level', Base.metadata,
    Column('fsite_level', Integer),
    schema='public'
)


class SLog(Base):
    __tablename__ = 's_log'
    __table_args__ = (
        PrimaryKeyConstraint('fno', name='s_log_pkey'),
        {'schema': 'public'}
    )

    fno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='编号')
    ftype: Mapped[Optional[int]] = mapped_column(Integer, comment='类型(1.定时场景 2.触发场景 3.手动场景 4.手机面板指令 5.手机测试指令)')
    fmacno: Mapped[Optional[str]] = mapped_column(String(20), comment='smart的mac')
    faction: Mapped[Optional[str]] = mapped_column(String(20), comment='动作')
    finstructions: Mapped[Optional[str]] = mapped_column(String(300), comment='指令')
    fsceneno: Mapped[Optional[int]] = mapped_column(Integer, comment='场景编号')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')
    fcreatetime: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='创建时间')
    fpoint_no: Mapped[Optional[str]] = mapped_column(String(20), comment='教室编号')
    method_name: Mapped[Optional[str]] = mapped_column(String(20), comment='方法名')


class SProperty(Base):
    __tablename__ = 's_property'
    __table_args__ = (
        PrimaryKeyConstraint('name', name='property_pkey'),
        {'schema': 'public'}
    )

    name: Mapped[str] = mapped_column(String(100), primary_key=True)
    value: Mapped[str] = mapped_column(String(255))
    memo: Mapped[Optional[str]] = mapped_column(String(100))


class STcElectricwarring(Base):
    __tablename__ = 's_tc_electricwarring'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='pk_s_tc_electricwarring'),
        Index('index_electricwarring', 'fmacno', 'fflag', 'fgetdate', 'fsite_no', 'fpoint_no'),
        {'comment': 'smart欠压过压过载记录', 'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='编号')
    fmacno: Mapped[str] = mapped_column(String(80), comment='设备mac')
    fflag: Mapped[int] = mapped_column(Integer, comment='报警类型(1过载2欠压3过压)')
    fgetdate: Mapped[datetime.datetime] = mapped_column(DateTime, comment='产生时间')
    fvoltage: Mapped[Optional[str]] = mapped_column(String(10), comment='电压')
    fflower: Mapped[Optional[str]] = mapped_column(String(10), comment='电流')
    fsite_no: Mapped[Optional[str]] = mapped_column(String(20), comment='市/区/学校')
    fpoint_no: Mapped[Optional[str]] = mapped_column(String(20), comment='教室编号')


class STcEquipmentDangerset(Base):
    __tablename__ = 's_tc_equipment_dangerset'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='pk_s_tc_equipment_dangerset'),
        Index('index__tc_equipment_dangerset', 'fsite_no', 'fpoint_no', 'fequipmentbarcode', 'feuipmentid', 'flevelno', 'fwarringdate'),
        {'comment': '设备报警信息', 'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, Sequence('s_tc_smartwarring_fentryid_seq', schema='public'), primary_key=True, comment='自增长')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='市/区/学校')
    fpoint_no: Mapped[str] = mapped_column(String(20), comment='教室编号')
    fequipmentbarcode: Mapped[str] = mapped_column(String(20), comment='固定资产码')
    feuipmentid: Mapped[int] = mapped_column(Integer, comment='设备ID')
    fdangerno: Mapped[str] = mapped_column(String(20), comment='报警编号')
    flevelno: Mapped[int] = mapped_column(Integer, comment='风险等级编号')
    fdescribe: Mapped[str] = mapped_column(String(200), comment='报警说明')
    fwarringdate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='报警时间')
    fenddate: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='结束时间')


class STcEquipmentInv(Base):
    __tablename__ = 's_tc_equipment_inv'
    __table_args__ = (
        PrimaryKeyConstraint('fequipmentbarcode', name='s_tc_equipment_inv_pkey'),
        Index('idx_s_tc_equipment_inv_feuipmentid', 'feuipmentid'),
        Index('idx_s_tc_equipment_inv_fpoint_no', 'fpoint_no'),
        Index('ix_s_tc_equipment_inv', 'feuipmentid', 'fmacno', 'fsite_no', 'fpoint_no'),
        {'comment': '设备台帐', 'schema': 'public'}
    )

    fequipmentbarcode: Mapped[str] = mapped_column(String(20), primary_key=True, comment='固定资产码')
    feuipmentid: Mapped[int] = mapped_column(Integer, comment='设备ID')
    fequipmenttag: Mapped[str] = mapped_column(String(80), comment='设备标签')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='学校编号')
    fmacno: Mapped[Optional[str]] = mapped_column(String(80), comment='机器码/序列号')
    fpoint_no: Mapped[Optional[str]] = mapped_column(String(20), comment='场地编号')
    fpoint_size: Mapped[Optional[str]] = mapped_column(String(20), comment='场地位置')
    flinkmac: Mapped[Optional[str]] = mapped_column(String(80), comment='排插MAC')
    flinkmark: Mapped[Optional[str]] = mapped_column(String(20), comment='标识符')
    fprocdate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='生产日期')
    fsupno: Mapped[Optional[str]] = mapped_column(String(20), comment='供应商编号')
    frecbillno: Mapped[Optional[str]] = mapped_column(String(20), comment='入库单号')
    frecdate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='入库日期')
    finstalldate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='安装日期')
    fmaintaindate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='下次保养日期')
    frepairdate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='最近维修日期')
    flosdate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='报废日期')
    fbuyprice: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 4), comment='设备原值')
    foldway: Mapped[Optional[int]] = mapped_column(Integer, comment='折旧方法')
    foldmoney: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 4), comment='累加折旧')
    flastmoney: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 4), comment='净值')
    flastrate: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 4), comment='净残值率')
    fversion: Mapped[Optional[str]] = mapped_column(String(10), comment='设备固件版本')
    fmarkstat: Mapped[Optional[str]] = mapped_column(String(10), comment='设备Switch状态')
    fvideourl: Mapped[Optional[str]] = mapped_column(String(100), comment='视频URL')
    fstate: Mapped[Optional[int]] = mapped_column(Integer, comment='设备状态')
    fip: Mapped[Optional[str]] = mapped_column(String(20), comment='设备IP地址')
    fport: Mapped[Optional[str]] = mapped_column(String(10), comment='设备IP端口')
    fmeeting: Mapped[Optional[int]] = mapped_column(Integer, comment='可预约(0不可/1可以)')
    fsubtitle: Mapped[Optional[str]] = mapped_column(String(100), comment='订阅主题')
    fpubtitle: Mapped[Optional[str]] = mapped_column(String(100), comment='发布主题')
    fpuborder: Mapped[Optional[str]] = mapped_column(String(20), comment='发布指令')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STcPointMoniter(Base):
    __tablename__ = 's_tc_point_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fsite_no', 'fpoint_no', 'fmoniter_date', name='s_tc_point_moniter_pkey'),
        {'comment': 'Smart电量每小时汇总', 'schema': 'public'}
    )

    fsite_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='地区编号')
    fpoint_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='教室编号')
    fmoniter_date: Mapped[datetime.datetime] = mapped_column(DateTime, primary_key=True, comment='用电日期+时间')
    fuse_num: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='用电量')


class STcSceneDetail(Base):
    __tablename__ = 's_tc_scene_detail'
    __table_args__ = (
        PrimaryKeyConstraint('fsceneno', 'fentryid', name='s_tc_scene_detail_pkey'),
        {'comment': '场景设备列表', 'schema': 'public'}
    )

    fsceneno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='场景编号 ')
    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='序号')
    faction: Mapped[str] = mapped_column(String(20), comment='控制指令')
    feuipmentid: Mapped[Optional[int]] = mapped_column(Integer, comment='设备ID')
    finstructions: Mapped[Optional[str]] = mapped_column(String(300), comment='控制指令')
    fequipmentbarcode: Mapped[Optional[str]] = mapped_column(String(32), comment='设备mac')
    factiontype: Mapped[Optional[int]] = mapped_column(Integer, comment='场景类型')
    fposition: Mapped[Optional[int]] = mapped_column(Integer, comment='设备第X只脚')


class STcSceneHead(Base):
    __tablename__ = 's_tc_scene_head'
    __table_args__ = (
        PrimaryKeyConstraint('fsceneno', name='s_tc_scene_head_pkey'),
        {'comment': '场景主表', 'schema': 'public'}
    )

    fsceneno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='场景编号 ')
    fscenename: Mapped[str] = mapped_column(String(80), comment='场景名称')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='所属学校')
    fteacherno: Mapped[str] = mapped_column(String(20), comment='用户编号')
    fscenetype: Mapped[int] = mapped_column(Integer, comment='场景类型(1定时设定/2设备联动/3用户定时场景/4用户手工场景/5净钛场景)')
    foperator: Mapped[str] = mapped_column(String(20), comment='操作员')
    fupddate: Mapped[datetime.datetime] = mapped_column(DateTime, comment='修改时间')
    frange: Mapped[int] = mapped_column(Integer, comment='范围级别(0学校/1楼层/2教室)')
    fairitem: Mapped[Optional[int]] = mapped_column(Integer, comment='空气项目')
    fwhere: Mapped[Optional[str]] = mapped_column(String(20), comment='符号(>/>=/=/<=/<)')
    fvalue: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='空气值')
    fexectime: Mapped[Optional[str]] = mapped_column(String(20), comment='执行时间')
    fexecweek1: Mapped[Optional[str]] = mapped_column(String(1), comment='周一执行')
    fexecweek2: Mapped[Optional[str]] = mapped_column(String(1), comment='周二执行')
    fexecweek3: Mapped[Optional[str]] = mapped_column(String(1), comment='周四执行')
    fexecweek4: Mapped[Optional[str]] = mapped_column(String(1), comment='周三执行')
    fexecweek5: Mapped[Optional[str]] = mapped_column(String(1), comment='周五执行')
    fexecweek6: Mapped[Optional[str]] = mapped_column(String(1), comment='周六执行')
    fexecweek7: Mapped[Optional[str]] = mapped_column(String(1), comment='周日执行')
    fvalue2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3))
    fwhere2: Mapped[Optional[str]] = mapped_column(String(20))


class STcSceneItem(Base):
    __tablename__ = 's_tc_scene_item'
    __table_args__ = (
        PrimaryKeyConstraint('fno', name='s_tc_scene_item_pkey'),
        {'schema': 'public'}
    )

    fsceneno: Mapped[int] = mapped_column(Integer, comment='场景编号')
    fno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='ID')
    fairitem: Mapped[int] = mapped_column(Integer, comment='空气项目')
    fwhere: Mapped[str] = mapped_column(String(10), comment='超标条件(>/>=/=/<=/<)')
    fvalue: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='超标值')
    fwhere2: Mapped[Optional[str]] = mapped_column(String(10), comment='达标条件(>/>=/=/<=/<)')
    fvalue2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='达标值')


class STcSceneLog(Base):
    __tablename__ = 's_tc_scene_log'
    __table_args__ = (
        PrimaryKeyConstraint('fseq', name='s_tc_scene_log_pkey'),
        {'schema': 'public'}
    )

    fsceneno: Mapped[int] = mapped_column(Integer, comment='场景编号')
    fseq: Mapped[int] = mapped_column(Integer, primary_key=True, comment='编号')
    fexectime: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='执行时间')
    fexestatus: Mapped[Optional[int]] = mapped_column(Integer, comment='执行情况')
    fentryid: Mapped[Optional[int]] = mapped_column(Integer, comment='场景明细序号')
    feqtflag: Mapped[Optional[int]] = mapped_column(Integer, comment='设备响应结果')


class STcScenePoint(Base):
    __tablename__ = 's_tc_scene_point'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='s_tc_scene_point_pkey'),
        Index('ix_s_tc_scene_point', 'fsceneno', 'fpoint_no'),
        {'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True)
    fsceneno: Mapped[int] = mapped_column(Integer)
    fpoint_no: Mapped[str] = mapped_column(String(50))


class STcSceneView(Base):
    __tablename__ = 's_tc_scene_view'
    __table_args__ = (
        PrimaryKeyConstraint('fsceneno', 'fpoint_no', 'fairitem', name='s_tc_scene_view_pkey'),
        {'schema': 'public'}
    )

    fsceneno: Mapped[int] = mapped_column(Integer, primary_key=True)
    fpoint_no: Mapped[str] = mapped_column(String(20), primary_key=True)
    fairitem: Mapped[int] = mapped_column(Integer, primary_key=True)
    fwhere: Mapped[Optional[str]] = mapped_column(String(10))
    fvalue: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3))
    fwhere2: Mapped[Optional[str]] = mapped_column(String(10))
    fvalue2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3))
    fscenetype: Mapped[Optional[int]] = mapped_column(Integer)


class STcSmartwarring(Base):
    __tablename__ = 's_tc_smartwarring'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='s_tc_smartwarring_pkey'),
        Index('ix_s_tc_smartwarring', 'fwarringno', 'fsite_no', 'fpoint_no', 'fgetdate'),
        {'comment': '当前用电量报警信息', 'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='编号 ')
    fwarringno: Mapped[int] = mapped_column(Integer, comment='报警编号 ')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='市/区/学校')
    fpoint_no: Mapped[str] = mapped_column(String(20), comment='教室编号')
    fdate_flag: Mapped[int] = mapped_column(Integer, comment='统计日期(1天/2月)')
    fscore_flag: Mapped[int] = mapped_column(Integer, comment='统计范围(1学校/2教室)')
    fcurnum: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='当前值')
    fbegnum: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='起始值')
    fendnum: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='起讫值')
    fdescribe: Mapped[str] = mapped_column(String(200), comment='报警说明')
    fsendmsg: Mapped[int] = mapped_column(Integer, comment='是否已发送消息')
    fsendemail: Mapped[int] = mapped_column(Integer, comment='是否已发送邮件')
    fgetdate: Mapped[datetime.datetime] = mapped_column(DateTime, comment='产生时间')


class STcSmartwarringUser(Base):
    __tablename__ = 's_tc_smartwarring_user'
    __table_args__ = (
        PrimaryKeyConstraint('fwarringno', 'fuserno', name='s_tc_smartwarring_user_pkey'),
        Index('ix_s_tc_smartwarring2', 'fwarringno', 'freadtime'),
        {'comment': '用电量报警用户信息', 'schema': 'public'}
    )

    fwarringno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='报警编号')
    fuserno: Mapped[str] = mapped_column(String(20), primary_key=True, comment='用户编号')
    freadtime: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='阅读时间')


class STdSmartMoniter(Base):
    __tablename__ = 's_td_smart_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_date', 'fsite_no', 'fpoint_no', name='s_td_smart_moniter_pkey'),
        {'comment': '每个地点每天用电量', 'schema': 'public'}
    )

    fmoniter_date: Mapped[datetime.datetime] = mapped_column(DateTime, primary_key=True, comment='日期 ')
    fsite_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='学校')
    fpoint_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='教室')
    fuse_num: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='用电量')


class SThPointMoniter(Base):
    __tablename__ = 's_th_point_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fsite_no', 'fpoint_no', 'fmoniter_date', name='s_th_point_moniter_pkey'),
        {'comment': 'Smart电量每小时汇总', 'schema': 'public'}
    )

    fsite_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='地区编号')
    fpoint_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='教室编号')
    fmoniter_date: Mapped[datetime.datetime] = mapped_column(DateTime, primary_key=True, comment='用电日期+时间')
    fuse_num: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='用电量')


class SThSmartMoniter(Base):
    __tablename__ = 's_th_smart_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fequipmentbarcode', 'fmoniter_date', name='s_th_smart_moniter_pkey'),
        {'comment': 'Smart电量每小时汇总', 'schema': 'public'}
    )

    fequipmentbarcode: Mapped[str] = mapped_column(String(20), primary_key=True, comment='设备条码')
    fmacno: Mapped[str] = mapped_column(String(80), comment='设备mac')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='地区编号')
    fmoniter_date: Mapped[datetime.datetime] = mapped_column(DateTime, primary_key=True, comment='用电日期')
    fuse_num: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='用电量')
    fpoint_no: Mapped[Optional[str]] = mapped_column(String(20), comment='教室编号')


class STmSmartMoniter(Base):
    __tablename__ = 's_tm_smart_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_month', 'fsite_no', 'fpoint_no', name='s_tm_smart_moniter_pkey'),
        {'comment': '每个地点每月用电量', 'schema': 'public'}
    )

    fmoniter_month: Mapped[str] = mapped_column(String(6), primary_key=True, comment='月份')
    fsite_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='学校')
    fpoint_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='教室')
    fuse_num: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='用电量')


class STpSmartMoniter(Base):
    __tablename__ = 's_tp_smart_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fid', name='s_tp_smart_moniter_pkey'),
        {'comment': 'Smart电量每小时保存', 'schema': 'public'}
    )

    fid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='序号')
    fmacno: Mapped[str] = mapped_column(String(80), comment='设备mac')
    fmoniter_date: Mapped[datetime.datetime] = mapped_column(DateTime, comment='用电日期')
    fuse_num: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='用电量')


class STsAiritem(Base):
    __tablename__ = 's_ts_airitem'
    __table_args__ = (
        PrimaryKeyConstraint('fairitem', name='s_ts_airitem_pkey'),
        {'comment': '空气项目字典', 'schema': 'public'}
    )

    fairitem: Mapped[int] = mapped_column(Integer, primary_key=True, comment='空气项目')
    fariname: Mapped[str] = mapped_column(String(20), comment='空气项目名称')
    ffield: Mapped[str] = mapped_column(String(20), comment='字段名')


class STsAirpoint(Base):
    __tablename__ = 's_ts_airpoint'
    __table_args__ = (
        PrimaryKeyConstraint('fairpoint_id', name='pk_s_ts_airpoint'),
        Index('index_s_ts_airpoint', 'fairpoint_no', 'fsite_no', 'fpoint_no', 'fstate'),
        {'comment': '通风节点资料', 'schema': 'public'}
    )

    fairpoint_id: Mapped[int] = mapped_column(Integer, Sequence('s_ts_equipment_info_feuipmentid_seq', schema='public'), primary_key=True, comment='节点ID')
    fairpoint_no: Mapped[str] = mapped_column(String(20), comment='节点编号')
    fairpoint_name: Mapped[str] = mapped_column(String(80), comment='节点名称')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='所属客户')
    fspec: Mapped[Optional[str]] = mapped_column(String(80), comment='型号')
    fmacno: Mapped[Optional[str]] = mapped_column(String(80), comment='机器码/序列号')
    fpoint_no: Mapped[Optional[str]] = mapped_column(String(20), comment='实验室编号')
    fpoint_size: Mapped[Optional[str]] = mapped_column(String(20), comment='教室位置')
    finstalldate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='安装日期')
    fip: Mapped[Optional[str]] = mapped_column(String(20), comment='设备IP地址')
    fport: Mapped[Optional[str]] = mapped_column(String(10), comment='设备IP端口')
    fnote: Mapped[Optional[str]] = mapped_column(String(80), comment='描述')
    fstate: Mapped[Optional[int]] = mapped_column(Integer, comment='设备状态')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsCheckType(Base):
    __tablename__ = 's_ts_check_type'
    __table_args__ = (
        PrimaryKeyConstraint('fchecktypeno', name='pk_s_ts_check_type'),
        {'comment': '设备巡查类型', 'schema': 'public'}
    )

    fchecktypeno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='巡查类型编号')
    fcheckname: Mapped[str] = mapped_column(String(20), comment='巡查类型名称')
    fmemo: Mapped[str] = mapped_column(String(80), comment='备注')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsCourse(Base):
    __tablename__ = 's_ts_course'
    __table_args__ = (
        PrimaryKeyConstraint('fcourseno', name='pk_s_ts_course'),
        {'comment': '课程表', 'schema': 'public'}
    )

    fcourseno: Mapped[str] = mapped_column(String(10), primary_key=True, comment='课程编号')
    fcoursename: Mapped[str] = mapped_column(String(40), comment='课程名称')
    fnote: Mapped[Optional[str]] = mapped_column(String(80), comment='描述')
    fstate: Mapped[Optional[int]] = mapped_column(Integer, comment='课程状态')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsDangerLevel(Base):
    __tablename__ = 's_ts_danger_level'
    __table_args__ = (
        PrimaryKeyConstraint('flevelno', name='s_ts_danger_level_pkey'),
        {'comment': '风险等级', 'schema': 'public'}
    )

    flevelno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='风险等级编号')
    flevelscre: Mapped[str] = mapped_column(String(20), comment='风险等级描述')
    flevelname: Mapped[str] = mapped_column(String(60), comment='风险等级名称')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改日期')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsDict(Base):
    __tablename__ = 's_ts_dict'
    __table_args__ = (
        PrimaryKeyConstraint('fdicttype', 'fdictno', name='s_ts_dict_pkey'),
        {'comment': '数据字典', 'schema': 'public'}
    )

    fdicttype: Mapped[int] = mapped_column(Integer, primary_key=True, comment='字典分类')
    fdictno: Mapped[str] = mapped_column(String(10), primary_key=True, comment='字典编号')
    fdictname: Mapped[str] = mapped_column(String(20), comment='字典内容')
    fdictmemo: Mapped[Optional[str]] = mapped_column(String(20), comment='备注')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改日期')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsEquipmentAction(Base):
    __tablename__ = 's_ts_equipment_action'
    __table_args__ = (
        PrimaryKeyConstraint('factionno', name='s_ts_equipment_action_pkey'),
        {'comment': '设备类型指令模板', 'schema': 'public'}
    )

    factionno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='自增长编号')
    fdictno: Mapped[int] = mapped_column(Integer, comment='设备类型编号')
    faction: Mapped[str] = mapped_column(String(100), comment='控制指令')
    fdescribe: Mapped[Optional[str]] = mapped_column(String(100), comment='指令描述')
    fimage: Mapped[Optional[str]] = mapped_column(String(100), comment='指令图标')
    findex: Mapped[Optional[int]] = mapped_column(Integer, comment='排序')
    scene_flag: Mapped[Optional[int]] = mapped_column(Integer, comment='是否在场景中显示(1/0)')


class STsEquipmentCheckitem(Base):
    __tablename__ = 's_ts_equipment_checkitem'
    __table_args__ = (
        PrimaryKeyConstraint('feuipmentid', 'fcheckitemno', name='s_ts_equipment_checkitem_pkey'),
        {'comment': '设备巡查项目', 'schema': 'public'}
    )

    feuipmentid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='设备ID')
    fline: Mapped[int] = mapped_column(Integer, comment='行号')
    fcheckitemno: Mapped[str] = mapped_column(String(20), primary_key=True, comment='巡查项目编号')
    fchecktypeno: Mapped[int] = mapped_column(Integer, comment='巡查类型')
    fcheckitemname: Mapped[Optional[str]] = mapped_column(String(80), comment='巡查项目名称')
    fcheckflag: Mapped[Optional[int]] = mapped_column(Integer, comment='是否启用(1是/0否)')
    fmemo: Mapped[Optional[str]] = mapped_column(String(80), comment='备注')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsEquipmentCheckset(Base):
    __tablename__ = 's_ts_equipment_checkset'
    __table_args__ = (
        PrimaryKeyConstraint('fsite_no', 'feuipmentid', 'fchecktypeno', name='s_ts_equipment_checkset_pkey'),
        {'comment': '设备巡查设定', 'schema': 'public'}
    )

    fsite_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='客户编号')
    feuipmentid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='设备ID')
    fchecktypeno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='巡查类型')
    fcheckday: Mapped[int] = mapped_column(Integer, comment='巡查天数')
    fmemo: Mapped[Optional[str]] = mapped_column(String(80), comment='巡查要求')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsEquipmentClass(Base):
    __tablename__ = 's_ts_equipment_class'
    __table_args__ = (
        PrimaryKeyConstraint('fclassstno', name='s_ts_equipment_class_pkey'),
        {'comment': '设备分类', 'schema': 'public'}
    )

    fclassstno: Mapped[str] = mapped_column(String(20), primary_key=True, comment='分类编号')
    fclassstname: Mapped[str] = mapped_column(String(60), comment='分类名称')
    fparentno: Mapped[Optional[str]] = mapped_column(String(20), comment='上级分类')
    fclassstyle: Mapped[Optional[int]] = mapped_column(Integer, comment='分类类别')
    flevel: Mapped[Optional[int]] = mapped_column(Integer, comment='分类级别')
    fdiscmonth: Mapped[Optional[int]] = mapped_column(Integer, comment='折扣年限')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改日期')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsEquipmentDangerset(Base):
    __tablename__ = 's_ts_equipment_dangerset'
    __table_args__ = (
        PrimaryKeyConstraint('feuipmentid', 'fdangerno', name='s_ts_equipment_dangerset_pkey'),
        {'comment': '设备报警字典', 'schema': 'public'}
    )

    feuipmentid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='设备ID')
    fline: Mapped[int] = mapped_column(Integer, comment='行号')
    fdangerno: Mapped[str] = mapped_column(String(20), primary_key=True, comment='报警编号')
    fdangername: Mapped[str] = mapped_column(String(80), comment='报警说明')
    flevelno: Mapped[int] = mapped_column(Integer, comment='风险等级编号')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsEquipmentDetail(Base):
    __tablename__ = 's_ts_equipment_detail'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='s_ts_equipment_detail_pkey'),
        Index('ix_s_ts_equipment_detail', 'feuipmentid', 'faction', 'fmark'),
        {'comment': '设备控制指令', 'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='序号')
    feuipmentid: Mapped[int] = mapped_column(Integer, comment='设备ID')
    faction: Mapped[str] = mapped_column(String(20), comment='控制指令')
    fdescribe: Mapped[str] = mapped_column(String(80), comment='指令描述')
    finstructions: Mapped[str] = mapped_column(String(1000), comment='设备指令')
    fmark: Mapped[str] = mapped_column(String(80), comment='设备标识')
    fnumflag: Mapped[Optional[int]] = mapped_column(Integer, comment='数字属性')
    fbegnum: Mapped[Optional[int]] = mapped_column(Integer, comment='最低值')
    fendnum: Mapped[Optional[int]] = mapped_column(Integer, comment='最高值')


class STsEquipmentDict(Base):
    __tablename__ = 's_ts_equipment_dict'
    __table_args__ = (
        PrimaryKeyConstraint('fdictno', name='s_ts_equipment_dict_pkey'),
        {'comment': '设备类型', 'schema': 'public'}
    )

    fdictno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='设备类型编号')
    fdictname: Mapped[str] = mapped_column(String(255), comment='设备类型名称')
    ftablename: Mapped[Optional[str]] = mapped_column(String(100), comment='码库表名')
    ficon: Mapped[Optional[str]] = mapped_column(String(20), comment='设备类型图标(轶伦APP)')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改日期')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')
    ficon2: Mapped[Optional[str]] = mapped_column(String(100), comment='设备类型图标(用电APP)')
    ftype: Mapped[Optional[int]] = mapped_column(Integer, comment='是否为设备(0:排插、1:设备)')
    fmark_num: Mapped[Optional[int]] = mapped_column(Integer, comment='排插插脚数量')
    fnumpre: Mapped[Optional[str]] = mapped_column(String(10))


class STsEquipmentFault(Base):
    __tablename__ = 's_ts_equipment_fault'
    __table_args__ = (
        PrimaryKeyConstraint('feuipmentid', 'ferrorno', name='s_ts_equipment_fault_pkey'),
        {'comment': '设备故障代码', 'schema': 'public'}
    )

    feuipmentid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='设备ID')
    ferrorno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='故障代码')
    fdangername: Mapped[Optional[str]] = mapped_column(String(60), comment='故障名称')
    ffaultno: Mapped[Optional[int]] = mapped_column(Integer, comment='故障等级')
    fprocday: Mapped[Optional[int]] = mapped_column(Integer, comment='处理天数')
    fprocword: Mapped[Optional[str]] = mapped_column(String(100), comment='处理手册')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改日期')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsEquipmentInfo(Base):
    __tablename__ = 's_ts_equipment_info'
    __table_args__ = (
        PrimaryKeyConstraint('feuipmentid', name='s_ts_equipment_info_pkey'),
        Index('idx_s_ts_equipment_info_feuipmentid', 'feuipmentid'),
        {'comment': '设备资料', 'schema': 'public'}
    )

    feuipmentid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='设备ID')
    fequipmentno: Mapped[str] = mapped_column(String(20), comment='设备编号')
    fequipmentname: Mapped[str] = mapped_column(String(80), comment='设备名称')
    fclassstno: Mapped[str] = mapped_column(String(20), comment='分类编号')
    fequipmenttype: Mapped[int] = mapped_column(Integer, comment='设备类型')
    fpanel: Mapped[int] = mapped_column(Integer, comment='控制面板(0--普通,1--红外,2--空开,3--窗帘,4--SNE空气净化器)')
    funit: Mapped[Optional[str]] = mapped_column(String(6), comment='计量单位')
    fbrand: Mapped[Optional[str]] = mapped_column(String(20), comment='品牌')
    fspec: Mapped[Optional[str]] = mapped_column(String(80), comment='型号')
    fuseyear: Mapped[Optional[int]] = mapped_column(Integer, comment='使用年限')
    fimage: Mapped[Optional[str]] = mapped_column(String(100), comment='设备图片')
    fbarcode: Mapped[Optional[str]] = mapped_column(String(40), comment='设备条码')
    fbuyprice: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 4), comment='设备报价')
    flowvoltage: Mapped[Optional[int]] = mapped_column(Integer, comment='最大电压')
    fheightvoltage: Mapped[Optional[int]] = mapped_column(Integer, comment='最高电压')
    felccurrent: Mapped[Optional[int]] = mapped_column(Integer, comment='电流')
    fip: Mapped[Optional[str]] = mapped_column(String(20), comment='TCP/IP')
    fport: Mapped[Optional[str]] = mapped_column(String(6), comment='PORT')
    fordday: Mapped[Optional[int]] = mapped_column(Integer, comment='采购周期')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')
    fcolor: Mapped[Optional[str]] = mapped_column(String(16))
    net_weight: Mapped[Optional[str]] = mapped_column(String(50), comment='容器皮重')
    fcharge: Mapped[Optional[int]] = mapped_column(Integer, comment='收费方式(1:按次/2:按小时)s_ts_dict.2019')
    fchargeprice: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 2), comment='收费标准')


class STsEquipmentMmset(Base):
    __tablename__ = 's_ts_equipment_mmset'
    __table_args__ = (
        PrimaryKeyConstraint('fsite_no', 'fmmtypeno', 'feuipmentid', name='s_ts_equipment_mmset_pkey'),
        {'comment': '设备保养设定', 'schema': 'public'}
    )

    fsite_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='客户编号')
    feuipmentid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='设备ID')
    fmmtypeno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='保养类型编号')
    fmmday: Mapped[int] = mapped_column(Integer, comment='保养天数')
    fmmlevelno: Mapped[int] = mapped_column(Integer, comment='保养级别编号')
    fmmworktime: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(8, 2), comment='保养工时')
    fmemo: Mapped[Optional[str]] = mapped_column(String(80), comment='备注')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsEquipmentPanel(Base):
    __tablename__ = 's_ts_equipment_panel'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='s_ts_equipment_panel_pkey'),
        Index('ix_s_ts_equipment_panel', 'feuipmenttype', 'faction'),
        {'comment': '设备控制面板', 'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='序号')
    feuipmenttype: Mapped[int] = mapped_column(Integer, comment='设备类型')
    frowno: Mapped[int] = mapped_column(Integer, comment='行号')
    faction: Mapped[str] = mapped_column(String(20), comment='控制指令')
    fx: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='按钮X')
    fy: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='按钮Y')
    fimage: Mapped[Optional[str]] = mapped_column(Text, comment='按钮(显示)图片')
    fseq: Mapped[Optional[int]] = mapped_column(Integer, comment='显示顺序')


class STsEquipmentPara(Base):
    __tablename__ = 's_ts_equipment_para'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='s_ts_equipment_para_pkey'),
        Index('ix_s_ts_equipment_para', 'feuipmentid'),
        {'comment': '设备输出参数', 'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, Sequence('s_ts_equipment_detail_fentryid_seq', schema='public'), primary_key=True, comment='序号')
    feuipmentid: Mapped[int] = mapped_column(Integer, comment='设备ID')
    fline: Mapped[int] = mapped_column(Integer, comment='行号')
    fparafield: Mapped[Optional[str]] = mapped_column(String(20), comment='参数字段')
    fparaname: Mapped[Optional[str]] = mapped_column(String(80), comment='参数描述')
    fparadict: Mapped[Optional[str]] = mapped_column(String(80), comment='参数字段 例如1表示开/0表示关')
    fparatype: Mapped[Optional[int]] = mapped_column(Integer, comment='参数类型:int/char')


class STsEquipmentRisk(Base):
    __tablename__ = 's_ts_equipment_risk'
    __table_args__ = (
        PrimaryKeyConstraint('friskno', name='s_ts_equipment_risk_pkey'),
        {'comment': '风险定义', 'schema': 'public'}
    )

    friskno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='等级编号')
    friskname: Mapped[str] = mapped_column(String(40), comment='等级说明')
    friskdesc: Mapped[str] = mapped_column(String(100), comment='等级描述')


class STsEquipmentState(Base):
    __tablename__ = 's_ts_equipment_state'
    __table_args__ = (
        PrimaryKeyConstraint('fstateno', name='s_ts_equipment_state_pkey'),
        {'comment': '设备状态', 'schema': 'public'}
    )

    fstateno: Mapped[str] = mapped_column(String(20), primary_key=True, comment='状态编号')
    fstatename: Mapped[str] = mapped_column(String(60), comment='状态名称')
    fdataflag: Mapped[int] = mapped_column(Integer, comment='数据采集')
    fcheckflag: Mapped[int] = mapped_column(Integer, comment='可巡查')
    fmaintainflag: Mapped[int] = mapped_column(Integer, comment='可保养')
    frepairflag: Mapped[int] = mapped_column(Integer, comment='可维修')
    fmovflag: Mapped[int] = mapped_column(Integer, comment='可调拨')
    fmrkflag: Mapped[int] = mapped_column(Integer, comment='可报废')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改日期')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsEquipmentWarring(Base):
    __tablename__ = 's_ts_equipment_warring'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='s_ts_equipment_warring_pkey'),
        Index('ix_s_ts_equipment_warring', 'feuipmentid', 'fwarringno'),
        {'comment': '设备报警字典', 'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='序号')
    feuipmentid: Mapped[int] = mapped_column(Integer, comment='设备ID')
    fline: Mapped[int] = mapped_column(Integer, comment='行号')
    fwarringno: Mapped[str] = mapped_column(String(20), comment='报警编码')
    fwarringname: Mapped[str] = mapped_column(String(80), comment='报警描述')
    fwarringlevel: Mapped[Optional[int]] = mapped_column(Integer, comment='风险等级')


class STsFaultDanger(Base):
    __tablename__ = 's_ts_fault_danger'
    __table_args__ = (
        PrimaryKeyConstraint('furgentno', name='s_ts_fault_danger_pkey'),
        {'comment': '紧急程度', 'schema': 'public'}
    )

    furgentno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='紧急程度编号')
    furgentname: Mapped[Optional[str]] = mapped_column(String(60), comment='紧急程度名称')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改日期')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsFaultLevel(Base):
    __tablename__ = 's_ts_fault_level'
    __table_args__ = (
        PrimaryKeyConstraint('ffaultno', name='s_ts_fault_level_pkey'),
        {'comment': '故障等级', 'schema': 'public'}
    )

    ffaultno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='故障等级编号')
    ffaultname: Mapped[Optional[str]] = mapped_column(String(60), comment='故障等级名称')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改日期')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsMaintain(Base):
    __tablename__ = 's_ts_maintain'
    __table_args__ = (
        PrimaryKeyConstraint('fid', name='s_ts_maintain_pkey'),
        {'schema': 'public'}
    )

    fid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='自增长ID')
    fentryid: Mapped[int] = mapped_column(Integer, comment='报警编号')
    ferrormemo: Mapped[str] = mapped_column(String(100), comment='故障描述')
    fwarringtype: Mapped[Optional[int]] = mapped_column(Integer, comment='报警类型：1.设备报警、2.空气报警、3.用电报警、4.空开报警')
    fsite_no: Mapped[Optional[str]] = mapped_column(String(20), comment='客户编号')
    freportuser: Mapped[Optional[str]] = mapped_column(String(20), comment='报修人员')
    freportdate: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='报修日期')
    frepairuser: Mapped[Optional[str]] = mapped_column(String(20), comment='工程师')
    fwcdate: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='完成日期')
    fbjnote: Mapped[Optional[str]] = mapped_column(String(100), comment='维修评价')
    fcheckdate: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='审核时间')
    fcheckuser: Mapped[Optional[str]] = mapped_column(String(20), comment='审核人员')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='修改时间')
    fbillstate: Mapped[Optional[int]] = mapped_column(Integer, comment='单据状态(1:已报修;2:已接单;3:维修中;4:已完成;5:已评价)')
    fcfdate: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='维保日期')
    dealresult: Mapped[Optional[str]] = mapped_column(String(100), comment='处理结果')
    fimage: Mapped[Optional[str]] = mapped_column(String(100), comment='图片')


class STsMaintainLevel(Base):
    __tablename__ = 's_ts_maintain_level'
    __table_args__ = (
        PrimaryKeyConstraint('fmmlevelno', name='pk_s_ts_maintain_level'),
        {'comment': '设备保养级别', 'schema': 'public'}
    )

    fmmlevelno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='保养级别编号')
    fmmlevelname: Mapped[str] = mapped_column(String(20), comment='保养级别名称')
    fmemo: Mapped[str] = mapped_column(String(80), comment='备注')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsMaintainType(Base):
    __tablename__ = 's_ts_maintain_type'
    __table_args__ = (
        PrimaryKeyConstraint('fmmtypeno', name='pk_s_ts_maintain_type'),
        {'comment': '设备保养类型', 'schema': 'public'}
    )

    fmmtypeno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='保养类型编号')
    fmmtypename: Mapped[str] = mapped_column(String(20), comment='保养类型名称')
    fmemo: Mapped[str] = mapped_column(String(80), comment='备注')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsMmitemSet(Base):
    __tablename__ = 's_ts_mmitem_set'
    __table_args__ = (
        PrimaryKeyConstraint('fsite_no', 'feuipmentid', 'fmmtypeno', 'fmmlevelno', name='s_ts_mmitem_set_pkey'),
        {'comment': '设备保养设定', 'schema': 'public'}
    )

    fsite_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='客户编号')
    feuipmentid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='设备ID')
    fmmtypeno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='保养类型')
    fmmlevelno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='保养级别编号')
    fmmday: Mapped[Optional[int]] = mapped_column(Integer, comment='保养天数')
    fmemo: Mapped[Optional[str]] = mapped_column(String(80), comment='备注')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsNextnum(Base):
    __tablename__ = 's_ts_nextnum'
    __table_args__ = (
        PrimaryKeyConstraint('fnumno', name='s_ts_nextnum_pkey'),
        {'comment': '单据编码', 'schema': 'public'}
    )

    fnumno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='单据类型')
    fnumname: Mapped[Optional[str]] = mapped_column(String(48), comment='单据名称')
    fnumpre: Mapped[Optional[str]] = mapped_column(String(10), comment='前缀')
    fnumwidth: Mapped[Optional[int]] = mapped_column(Integer, comment='长度')
    fnumnext: Mapped[Optional[int]] = mapped_column(Integer, comment='下一个号码')
    finc: Mapped[Optional[int]] = mapped_column(Integer, comment='递增量')
    freftab: Mapped[Optional[str]] = mapped_column(String(10), comment='后缀')
    fmemo: Mapped[Optional[str]] = mapped_column(String(48), comment='备注')


class STsPartClass(Base):
    __tablename__ = 's_ts_part_class'
    __table_args__ = (
        PrimaryKeyConstraint('fclassstno', name='s_ts_part_class_pkey'),
        {'comment': '零件分类', 'schema': 'public'}
    )

    fclassstno: Mapped[str] = mapped_column(String(20), primary_key=True, comment='分类编号')
    fclassstname: Mapped[Optional[str]] = mapped_column(String(60), comment='分类名称')
    fparentno: Mapped[Optional[str]] = mapped_column(String(20), comment='上级分类')
    fclassstyle: Mapped[Optional[int]] = mapped_column(Integer, comment='分类类别')
    flevel: Mapped[Optional[int]] = mapped_column(Integer, comment='分类级别')
    fdiscmonth: Mapped[Optional[int]] = mapped_column(Integer, comment='折扣年限')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改日期')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsPartInfo(Base):
    __tablename__ = 's_ts_part_info'
    __table_args__ = (
        PrimaryKeyConstraint('fpartid', name='s_ts_part_info_pkey'),
        {'comment': '零件资料', 'schema': 'public'}
    )

    fpartid: Mapped[int] = mapped_column(Integer, Sequence('s_ts_equipment_info_feuipmentid_seq', schema='public'), primary_key=True, comment='零件ID')
    fpartno: Mapped[str] = mapped_column(String(20), comment='零件编号')
    fpartname: Mapped[str] = mapped_column(String(80), comment='零件名称')
    fclassstno: Mapped[str] = mapped_column(String(20), comment='分类编号')
    fpanel: Mapped[int] = mapped_column(Integer, comment='是否有控制面板')
    funit: Mapped[Optional[str]] = mapped_column(String(6), comment='计量单位')
    fbrand: Mapped[Optional[str]] = mapped_column(String(20), comment='品牌')
    fspec: Mapped[Optional[str]] = mapped_column(String(80), comment='型号')
    fuseyear: Mapped[Optional[int]] = mapped_column(Integer, comment='使用年限')
    fimage: Mapped[Optional[str]] = mapped_column(String(100), comment='零件图片')
    fbarcode: Mapped[Optional[str]] = mapped_column(String(40), comment='零件条码')
    fbuyprice: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 4), comment='零件报价')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsSmartversion(Base):
    __tablename__ = 's_ts_smartversion'
    __table_args__ = (
        PrimaryKeyConstraint('fmac', name='s_ts_smartversion_pkey'),
        {'schema': 'public'}
    )

    fid: Mapped[int] = mapped_column(Integer, comment='自增长ID')
    fmac: Mapped[str] = mapped_column(String(20), primary_key=True, comment='机器码mac')
    fver: Mapped[Optional[str]] = mapped_column(String(50), comment='版本号')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='更新时间')


class STsSmartwarring(Base):
    __tablename__ = 's_ts_smartwarring'
    __table_args__ = (
        PrimaryKeyConstraint('fwarringno', name='s_ts_smartwarring_pkey'),
        Index('ix_s_ts_smartwarring', 'fsite_no'),
        {'comment': '用电量报警设定', 'schema': 'public'}
    )

    fwarringno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='编号')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='市/区/学校')
    fdate_flag: Mapped[int] = mapped_column(Integer, comment='统计日期(1天/2月)')
    fscore_flag: Mapped[int] = mapped_column(Integer, comment='统计范围(1学校/2教室)')
    fbegnum: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='起始值')
    fendnum: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='起讫值')
    fdescribe: Mapped[str] = mapped_column(String(200), comment='报警说明')
    flevelno: Mapped[int] = mapped_column(Integer, comment='风险等级编号')
    fsendmsg: Mapped[int] = mapped_column(Integer, comment='是否发送消息')
    fsendemail: Mapped[int] = mapped_column(Integer, comment='是否发送邮件')
    fstate: Mapped[int] = mapped_column(Integer, comment='设定状态(1正常/0停止)')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')


class STsSmartwarringPoint(Base):
    __tablename__ = 's_ts_smartwarring_point'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='s_ts_smartwarring_point_pkey'),
        Index('ix_s_ts_smartwarring_point', 'fwarringno', 'fpoint_no'),
        {'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True)
    fwarringno: Mapped[int] = mapped_column(Integer)
    fpoint_no: Mapped[str] = mapped_column(String(20))


class STsSmartwarringUser(Base):
    __tablename__ = 's_ts_smartwarring_user'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='s_ts_smartwarring_user_pkey'),
        Index('ix_s_ts_smartwarring_user', 'fwarringno', 'fuserno'),
        {'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True)
    fwarringno: Mapped[int] = mapped_column(Integer)
    fuserno: Mapped[str] = mapped_column(String(20))


class STsSupplier(Base):
    __tablename__ = 's_ts_supplier'
    __table_args__ = (
        PrimaryKeyConstraint('fsupno', 'fsite_no', name='pk_s_ts_supplier'),
        {'comment': '供应商资料', 'schema': 'public'}
    )

    fsupno: Mapped[str] = mapped_column(String(20), primary_key=True, comment='供应商编号')
    fsupname: Mapped[str] = mapped_column(String(100), comment='供应商名称')
    fsite_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='所属客户')
    ftype: Mapped[int] = mapped_column(Integer, comment='供应商类型(s_ts_dict=2018)')
    fsupkind: Mapped[int] = mapped_column(Integer, comment='供应商性质\r\n1:危化品\r\n2:耗材\r\n3:设备\r\n4:处置企业\r\n6:质检企业')
    fstate: Mapped[int] = mapped_column(Integer, comment='供应商状态(1正常/0停止)')
    faccname: Mapped[Optional[str]] = mapped_column(String(100), comment='开户名称')
    faccno: Mapped[Optional[str]] = mapped_column(String(100), comment='账号号码')
    faccbank: Mapped[Optional[str]] = mapped_column(String(100), comment='开户银行')
    fcorptaxno: Mapped[Optional[str]] = mapped_column(String(100), comment='税务登记号')
    fofficeaddress: Mapped[Optional[str]] = mapped_column(String(100), comment='办公地址')
    fprovince: Mapped[Optional[str]] = mapped_column(String(20), comment='省份')
    fcity: Mapped[Optional[str]] = mapped_column(String(20), comment='城市')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')


class STsSupplierCertify(Base):
    __tablename__ = 's_ts_supplier_certify'
    __table_args__ = (
        PrimaryKeyConstraint('fsupno', 'fentryid', name='pk_s_ts_supplier_certify'),
        {'comment': '供应商证件', 'schema': 'public'}
    )

    fsupno: Mapped[str] = mapped_column(String(20), primary_key=True, comment='供应商编号')
    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='序号')
    fcertifyid: Mapped[int] = mapped_column(Integer, comment='证件类型')
    fcertifyno: Mapped[str] = mapped_column(String(30), comment='证件号码')
    fvaliddate: Mapped[datetime.datetime] = mapped_column(DateTime, comment='有效终止日')
    ffilename: Mapped[Optional[str]] = mapped_column(String(100), comment='图片文件')
    fexplanation: Mapped[Optional[str]] = mapped_column(String(50), comment='备注')


class STsSupplierEmp(Base):
    __tablename__ = 's_ts_supplier_emp'
    __table_args__ = (
        PrimaryKeyConstraint('fsupno', 'fentryid', name='pk_s_ts_supplier_emp'),
        {'comment': '供应商联系人', 'schema': 'public'}
    )

    fsupno: Mapped[str] = mapped_column(String(20), primary_key=True, comment='供应商编号')
    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='序号')
    flinkman: Mapped[str] = mapped_column(String(20), comment='联系人')
    fphone: Mapped[str] = mapped_column(String(15), comment='手机')
    flinkdpt: Mapped[Optional[str]] = mapped_column(String(20), comment='部门')
    flinkplace: Mapped[Optional[str]] = mapped_column(String(20), comment='职务')
    ftelno: Mapped[Optional[str]] = mapped_column(String(20), comment='电话')
    femail: Mapped[Optional[str]] = mapped_column(String(50), comment='邮箱')
    fexplanation: Mapped[Optional[str]] = mapped_column(String(50), comment='备注')


class STsUser(Base):
    __tablename__ = 's_ts_user'
    __table_args__ = (
        PrimaryKeyConstraint('fuserno', name='s_ts_user_pkey'),
        Index('ix_s_ts_user', 'fuserno', 'fsite_no', 'fstate'),
        {'comment': '空气与Smart手机人员资料', 'schema': 'public'}
    )

    fuserno: Mapped[str] = mapped_column(String(10), primary_key=True, comment='用户编号')
    fusername: Mapped[str] = mapped_column(String(20), comment='用户姓名')
    fpassword: Mapped[str] = mapped_column(String(10), comment='密码')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='密码')
    fstate: Mapped[int] = mapped_column(Integer, comment='状态')
    fzw: Mapped[Optional[str]] = mapped_column(String(20), comment='职务')
    fmemo: Mapped[Optional[str]] = mapped_column(String(80), comment='备注')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作者')


class STySmartMoniter(Base):
    __tablename__ = 's_ty_smart_moniter'
    __table_args__ = (
        PrimaryKeyConstraint('fmoniter_year', 'fsite_no', 'fpoint_no', name='s_ty_smart_moniter_pkey'),
        {'comment': '每个地点年份用电量', 'schema': 'public'}
    )

    fmoniter_year: Mapped[int] = mapped_column(Integer, primary_key=True, comment='年份')
    fsite_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='学校')
    fpoint_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='教室')
    fuse_num: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='用电量')


class SUploadInfo(Base):
    __tablename__ = 's_upload_info'
    __table_args__ = (
        PrimaryKeyConstraint('fbiztype', 'fentryid', name='s_upload_info_pkey'),
        {'comment': '数据同步定义表', 'schema': 'public'}
    )

    fbiztype: Mapped[int] = mapped_column(Integer, primary_key=True)
    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True)
    fbizname: Mapped[str] = mapped_column(String(80))
    fbizdata: Mapped[str] = mapped_column(String(500))
    fbizdate: Mapped[str] = mapped_column(String(10))
    fbiztime: Mapped[Optional[int]] = mapped_column(Integer)
    fbiztable: Mapped[Optional[str]] = mapped_column(String(10))
    fprocdate: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime)
    fprocstate: Mapped[Optional[int]] = mapped_column(Integer)


class Script(Base):
    __tablename__ = 'script'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='script_pkey'),
        {'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True)
    script_type: Mapped[Optional[int]] = mapped_column(Integer, comment='1.python脚本')
    url: Mapped[Optional[str]] = mapped_column(String(164), comment='脚本的本地路径')
    param_id: Mapped[Optional[int]] = mapped_column(BigInteger, comment='运行方法的所需参数字段')
    fun: Mapped[Optional[str]] = mapped_column(String(64), comment='要运行的方法名')


class ScriptParam(Base):
    __tablename__ = 'script_param'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='script_param_pkey'),
        {'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True)
    value_type: Mapped[Optional[int]] = mapped_column(SmallInteger, comment='1.int 0.string(当前设计脚本的传参问题：1.在传入多个参数时不支持一个为int,一个为string，参数类型应当保持一致类型，如果参数不一致可以在脚本中进行强制类型转换)')
    param_value: Mapped[Optional[str]] = mapped_column(String(255), comment='参数值')
    param_id: Mapped[Optional[int]] = mapped_column(BigInteger, comment='脚本内方法所需参数')


class TbInform(Base):
    __tablename__ = 'tb_inform'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='tb_inform_pkey'),
        {'comment': '通知表 -----定时任务查询进行发送', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True)
    sender: Mapped[Optional[str]] = mapped_column(String(32), comment='发送人')
    receivedby: Mapped[Optional[str]] = mapped_column(String(32), comment='接收人')
    title: Mapped[Optional[str]] = mapped_column(String(64), comment='消息标题')
    content: Mapped[Optional[str]] = mapped_column(Text, comment='发送内容')
    send_time: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=0), comment='发送时间')
    status: Mapped[Optional[int]] = mapped_column(SmallInteger, comment='通知状态：0.等待发送1.发送完成 2.发送失败 3.用户未配置是否接收通知')
    send_mail: Mapped[Optional[int]] = mapped_column(SmallInteger, server_default=text('0'), comment='发送邮件状态：1.发送成功 0.发送失败')
    send_phone_note: Mapped[Optional[int]] = mapped_column(SmallInteger, server_default=text('0'), comment='发送短信状态：1.发送成功 0.发送失败')
    send_enterprise_wechat: Mapped[Optional[int]] = mapped_column(SmallInteger, server_default=text('0'), comment='发送企业微信状态：1.发送成功 0.发送失败')
    send_dingding: Mapped[Optional[int]] = mapped_column(SmallInteger, comment='发送钉钉状态：1.发送成功 0.发送失败')


class TbInformConfig(Base):
    __tablename__ = 'tb_inform_config'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='tb_user_config_pkey'),
        {'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True, comment='id')
    user_id: Mapped[Optional[int]] = mapped_column(Integer, comment='用户id')
    receive_mail: Mapped[Optional[int]] = mapped_column(SmallInteger, comment='是否接收邮件 1.是 0.否')
    receive_phone_note: Mapped[Optional[int]] = mapped_column(SmallInteger, comment='是否接收手机短信 1.是 0.否')
    receive_enterprise_wechat: Mapped[Optional[int]] = mapped_column(SmallInteger, comment='是否接收企业微信 1.是 0.否')
    receive_dingding_chat: Mapped[Optional[int]] = mapped_column(SmallInteger, comment='是否接收钉钉的消息 1.是 0.否')


class TbOrder(Base):
    __tablename__ = 'tb_order'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='tb_order_pkey'),
        {'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True, comment='id')
    third_no: Mapped[Optional[str]] = mapped_column(String(64), comment='支付流水号')
    status: Mapped[Optional[int]] = mapped_column(SmallInteger, comment='订单状态:0-创建;1-支付完成;2.交易关闭')
    amount: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(10, 2), comment='支付金额')
    price: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(10, 2), comment='商品金额')
    pay_type: Mapped[Optional[int]] = mapped_column(SmallInteger, comment='支付类型：支付宝，微信')
    pay_status: Mapped[Optional[int]] = mapped_column(SmallInteger, comment='支付状态，0-未支付;1-支付完成;2-退款中;3-退款完成')
    pay_time: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=0), comment='支付时间')


class TbOrderDetail(Base):
    __tablename__ = 'tb_order_detail'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='meeting_order_pkey'),
        {'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, Sequence('meeting_order_id_seq', schema='public'), primary_key=True)
    order_no: Mapped[Optional[str]] = mapped_column(String(32), comment='订单id')
    point_no: Mapped[Optional[str]] = mapped_column(String(64), comment='房间id')
    amount: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(32, 2), comment='剩余未付款金额')
    remark: Mapped[Optional[str]] = mapped_column(String(255), comment='备注')
    room_power: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(64, 4), comment='用电量')
    order_created_time: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=0), comment='订单创建时间')
    point_name: Mapped[Optional[str]] = mapped_column(String(64), comment='房间名')
    site_no: Mapped[Optional[str]] = mapped_column(String(20), comment='所属客户')
    third_no: Mapped[Optional[str]] = mapped_column(String(64), comment='订单支付流水号')


class TcEngpartInv(Base):
    __tablename__ = 'tc_engpart_inv'
    __table_args__ = (
        PrimaryKeyConstraint('fmonth', 'fengno', 'fpartid', name='tc_engpart_inv_pkey'),
        {'comment': '工程师零件库存', 'schema': 'public'}
    )

    fmonth: Mapped[str] = mapped_column(String(20), primary_key=True, comment='单据编号')
    fengno: Mapped[str] = mapped_column(String(20), primary_key=True, comment='工程师编号')
    fpartid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='零件ID')
    fbegqty: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 4), comment='期初')
    frecqty: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 4), comment='领用')
    foutqty: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 4), comment='退回')
    fuseqty: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 4), comment='使用')
    fbalqty: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 4), comment='期末')


class TcPartInv(Base):
    __tablename__ = 'tc_part_inv'
    __table_args__ = (
        PrimaryKeyConstraint('fmonth', 'fpartid', name='tc_part_inv_pkey'),
        {'comment': '零件库存', 'schema': 'public'}
    )

    fmonth: Mapped[str] = mapped_column(String(20), primary_key=True, comment='单据编号')
    fpartid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='零件ID')
    fbegqty: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 4), comment='期初')
    frecqty: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 4), comment='入库')
    foutqty: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 4), comment='领用')
    finqty: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 4), comment='退回')
    fmrkqty: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 4), comment='报废')
    fbalqty: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 4), comment='期末')


t_tmp_equipment_inv = Table(
    'tmp_equipment_inv', Base.metadata,
    Column('fuserno', String(10), nullable=False, comment='用户编号'),
    Column('fsite_name', String(48), nullable=False, comment='客户名称'),
    Column('fpoint_name', String(48), nullable=False, comment='存放地点'),
    Column('fequipmentname', String(80), nullable=False, comment='设备名称'),
    Column('fequipmenttag', String(80), nullable=False, comment='设备标签'),
    Column('fpoint_size', String(20), comment='存放位置'),
    Column('fmacno', String(80)),
    Column('flinkmac', String(80), comment='排插MAC'),
    Column('flinkmark', String(20), comment='标识符'),
    Column('finstalldate', DateTime, comment='安装日期'),
    Column('fip', String(20), comment='设备IP地址'),
    Column('fport', String(10), comment='设备IP端口'),
    Column('fvideourl', String(100), comment='视频URL'),
    Index('ix_tmp_equipment_inv', 'fuserno'),
    schema='public',
    comment='新学校导入设备资料'
)


t_tmp_point_inv = Table(
    'tmp_point_inv', Base.metadata,
    Column('fuserno', String(10), nullable=False, comment='用户编号'),
    Column('fsite_name', String(48), nullable=False, comment='客户名称'),
    Column('fpoint_no', String(20), nullable=False, comment='监测点编号'),
    Column('fpoint_name', String(48), nullable=False, comment='监测点名称'),
    Column('fparent_point', String(48), comment='上级监测点'),
    Column('ftype', String(10), nullable=False, comment='类型'),
    Column('fpoint_l', Numeric(20, 10), comment='纬度'),
    Column('fpoint_d', Numeric(20, 10), comment='经度'),
    Column('fpoint_h', Numeric(20, 10), comment='高度'),
    Column('fpoint_w', Numeric(20, 10), comment='宽度'),
    Index('ix_tmp_equipment_inv_copy1', 'fuserno'),
    schema='public',
    comment='新学校导入设备资料'
)


t_tmp_tc_equipment_inv = Table(
    'tmp_tc_equipment_inv', Base.metadata,
    Column('fequipmentbarcode', String(20), nullable=False),
    Column('feuipmentid', Integer, nullable=False),
    Column('fmacno', String(80)),
    Column('fequipmenttag', String(80)),
    Column('fsite_no', String(20), nullable=False),
    Column('fpoint_no', String(20)),
    Column('flinkmac', String(80)),
    Column('flinkmark', String(20)),
    Column('frecbillno', String(20)),
    Column('frecdate', DateTime),
    Column('fprocdate', DateTime),
    Column('flosdate', DateTime),
    Column('flinkflag', Integer),
    Column('fstate', Integer),
    Column('fversion', String(10)),
    Column('fmarkstat', String(10)),
    schema='public'
)


class TsNextnum(Base):
    __tablename__ = 'ts_nextnum'
    __table_args__ = (
        PrimaryKeyConstraint('feuipmenttype', name='ts_nextnum_pkey'),
        {'comment': '固定资产编码表', 'schema': 'public'}
    )

    feuipmenttype: Mapped[str] = mapped_column(String(3), primary_key=True, comment='设备类型')
    fnextnum: Mapped[Optional[int]] = mapped_column(Integer, comment='下个编号')
    fnumname: Mapped[Optional[str]] = mapped_column(String(48), comment='类型名称')
    fnumpre: Mapped[Optional[str]] = mapped_column(String(10), comment='前缀')
    fnumwidth: Mapped[Optional[int]] = mapped_column(Integer, comment='长度')
    finc: Mapped[Optional[int]] = mapped_column(Integer, comment='递增量')
    freftab: Mapped[Optional[str]] = mapped_column(String(10), comment='后缀')
    fmemo: Mapped[Optional[str]] = mapped_column(String(48), comment='备注')


class TsTenant(Base):
    __tablename__ = 'ts_tenant'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='ts_tenant_pkey'),
        UniqueConstraint('fno', name='uk_ts_tenant_fno'),
        {'comment': '客户(租户)表', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, Sequence('event_id_seq', schema='public'), primary_key=True, comment='序列号')
    fno: Mapped[str] = mapped_column(String(32), comment='客户编号')
    fname: Mapped[Optional[str]] = mapped_column(String(255), comment='客户名称')
    flinkman: Mapped[Optional[str]] = mapped_column(String(50), comment='联系人信息')
    faddress: Mapped[Optional[str]] = mapped_column(String(255), comment='客户地址')
    fapiurl: Mapped[Optional[str]] = mapped_column(String(100), comment='服务Api地址')
    fbegindate: Mapped[Optional[datetime.date]] = mapped_column(Date, comment='授权开始日期')
    fenddate: Mapped[Optional[datetime.date]] = mapped_column(Date, comment='授权结束日期')
    fstatus: Mapped[Optional[int]] = mapped_column(Integer, comment='状态0.禁用 1.启用')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='操作日期')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作人')


class TyReportedData(Base):
    __tablename__ = 'ty_reported_data'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='ty_reported_data_pkey'),
        {'comment': '创建失败创建自增id序列\r\n'
                'CREATE SEQUENCE IF NOT EXISTS ty_reported_data_id_seq;',
     'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True, comment='id')
    equipment_id: Mapped[Optional[str]] = mapped_column(String(64), comment='天翼设备编号')
    fsite_no: Mapped[Optional[str]] = mapped_column(String(32), comment='市/区/学校')
    fpoint_no: Mapped[Optional[str]] = mapped_column(String(32), comment='教室编号')
    fdescribe: Mapped[Optional[str]] = mapped_column(String(255), comment='报警说明')
    fsendmsg: Mapped[Optional[int]] = mapped_column(Integer, comment='是否已发送消息')
    fsendemail: Mapped[Optional[int]] = mapped_column(Integer, comment='是否已发送邮件')
    devtype: Mapped[Optional[str]] = mapped_column(String(10), comment='产品类型:1门磁探测器；2水浸；3烟感；4燃气；5红外感应；7紧急按钮；1728传感器；')
    csq: Mapped[Optional[str]] = mapped_column(String(10), comment='信号强度')
    batvoltage1: Mapped[Optional[str]] = mapped_column(String(10), comment='0.1v为单位，主电池电压，30表示3.0V,使用市电产品传输数据0xFF')
    batvoltage2: Mapped[Optional[str]] = mapped_column(String(10), comment='0.1v为单位，通讯部分电池电压，只有一个电池或使用市电产品传输数据-1')
    temperature: Mapped[Optional[str]] = mapped_column(String(10), comment='温度，单位:摄氏度。有符号字符型，范围-127~127℃。无温度传感器的产品传输数据0x80')
    status: Mapped[Optional[str]] = mapped_column(String(10), comment='产品状态：0状态正常;1布防;2温度报警;3故障;4电池2低压;5电池1低压;6防拆状态;7报警消音;8报警')
    evt: Mapped[Optional[str]] = mapped_column(String(10), comment='触发事件:   0无事件;1心跳;2报警;3报警恢复;4防拆报警;5防拆报警恢复;6电池低压;7电池电压恢复;8电池2低压(如果有双电池);9电池2电压恢复;10自检;11通讯板自检;12内部通讯异常;13内部通讯恢复;14探测器故障;15探测器故障恢复;16温度报警;17温度报警恢复;18人体红外报警(烟感);19人体红外报警恢复（烟感;\r\n32下发命令回复；')
    iccid: Mapped[Optional[int]] = mapped_column(Integer, comment='设备卡的ICCID')
    softversion: Mapped[Optional[str]] = mapped_column(String(10), comment='软件版本（如V1.0，10)')
    hardversion: Mapped[Optional[str]] = mapped_column(String(10), comment='硬件版本（如V1.0，10)')
    fgetdate: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='发送时间')


class UserSite(Base):
    __tablename__ = 'user_site'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='user_site_pkey'),
        {'comment': '用户和地区关系表', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
    user_id: Mapped[Optional[int]] = mapped_column(BigInteger)
    fsite_no_belong: Mapped[Optional[str]] = mapped_column(String(20))
    fsite_no_manage: Mapped[Optional[str]] = mapped_column(String(20))


t_view_air_brand = Table(
    'view_air_brand', Base.metadata,
    Column('serial', Integer),
    Column('brand_cn', String),
    Column('brand_en', String),
    Column('model', String),
    Column('pinyin', String),
    Column('code', Integer),
    schema='public',
    comment='空气净化器品牌'
)


t_view_air_code = Table(
    'view_air_code', Base.metadata,
    Column('code', Integer),
    Column('control', String),
    schema='public',
    comment='空气净化器控制码'
)


t_view_arc_brand = Table(
    'view_arc_brand', Base.metadata,
    Column('serial', Integer),
    Column('brand_cn', String),
    Column('brand_en', String),
    Column('model', String),
    Column('pinyin', String),
    Column('code', Integer),
    schema='public',
    comment='空调品牌'
)


t_view_arc_code = Table(
    'view_arc_code', Base.metadata,
    Column('code', Integer),
    Column('control', String),
    schema='public',
    comment='空调控制码'
)


t_view_aud_brand = Table(
    'view_aud_brand', Base.metadata,
    Column('serial', Integer),
    Column('brand_cn', String),
    Column('brand_en', String),
    Column('model', String),
    Column('pinyin', String),
    Column('code', Integer),
    schema='public',
    comment='音响品牌'
)


t_view_aud_code = Table(
    'view_aud_code', Base.metadata,
    Column('code', Integer),
    Column('control', String),
    schema='public',
    comment='音响控制码'
)


t_view_enger = Table(
    'view_enger', Base.metadata,
    Column('id', BigInteger),
    Column('username', String(64)),
    schema='public'
)


t_view_fan_brand = Table(
    'view_fan_brand', Base.metadata,
    Column('serial', Integer),
    Column('brand_cn', String),
    Column('brand_en', String),
    Column('model', String),
    Column('pinyin', String),
    Column('code', Integer),
    schema='public',
    comment='风扇品牌'
)


t_view_fan_code = Table(
    'view_fan_code', Base.metadata,
    Column('code', Integer),
    Column('control', String),
    schema='public',
    comment='风扇控制码'
)


t_view_lamp_brand = Table(
    'view_lamp_brand', Base.metadata,
    Column('serial', Integer),
    Column('brand_cn', String),
    Column('brand_en', String),
    Column('model', String),
    Column('pinyin', String),
    Column('code', Integer),
    schema='public',
    comment='智能灯品牌'
)


t_view_lamp_code = Table(
    'view_lamp_code', Base.metadata,
    Column('code', Integer),
    Column('control', String),
    schema='public',
    comment='智能灯控制码'
)


t_view_network = Table(
    'view_network', Base.metadata,
    Column('fnewwork', Text),
    schema='public',
    comment='联网情况'
)


t_view_pjt_brand = Table(
    'view_pjt_brand', Base.metadata,
    Column('serial', Integer),
    Column('brand_cn', String),
    Column('brand_en', String),
    Column('model', String),
    Column('pinyin', String),
    Column('code', Integer),
    schema='public',
    comment='投影仪品牌'
)


t_view_pjt_code = Table(
    'view_pjt_code', Base.metadata,
    Column('code', Integer),
    Column('control', String),
    schema='public',
    comment='投影仪控制码'
)


t_view_smart_moniter = Table(
    'view_smart_moniter', Base.metadata,
    Column('fmacno', String),
    Column('fuse_num', Numeric),
    Column('fmoniter_date', DateTime),
    schema='public',
    comment='Smart电量每小时保存'
)


t_view_tp_quality_w = Table(
    'view_tp_quality_w', Base.metadata,
    Column('fid', Integer),
    Column('fmacno', String),
    Column('setweight', Numeric),
    Column('weight', Numeric),
    Column('gear', Integer),
    Column('count', Integer),
    Column('state', String),
    Column('ftime', String),
    Column('updatetime', DateTime),
    schema='public',
    comment='智量仪重量'
)


t_view_tv_brand = Table(
    'view_tv_brand', Base.metadata,
    Column('serial', Integer),
    Column('brand_cn', String),
    Column('brand_en', String),
    Column('model', String),
    Column('pinyin', String),
    Column('code', Integer),
    schema='public',
    comment='电视品牌'
)


t_view_tv_code = Table(
    'view_tv_code', Base.metadata,
    Column('code', Integer),
    Column('control', String),
    schema='public',
    comment='电视控制码'
)


class WAttributeItem(Base):
    __tablename__ = 'w_attribute_item'
    __table_args__ = (
        PrimaryKeyConstraint('attribute_item_id', name='pk_w_attribute_item'),
        {'comment': 'xt_attribute_item ', 'schema': 'public'}
    )

    attribute_item_id: Mapped[int] = mapped_column(Integer, primary_key=True, comment='主键id')
    attribute_item_value: Mapped[str] = mapped_column(String(50), comment='属性值代码值')
    attribute_item_code: Mapped[str] = mapped_column(String(50), comment='属性值代码')
    attribute_sort: Mapped[Optional[int]] = mapped_column(Integer, comment='排序')
    attribute_item_status: Mapped[Optional[int]] = mapped_column(Integer, comment='状态：1有效；0无效')
    attribute_item_level: Mapped[Optional[int]] = mapped_column(Integer, comment='级别（目前都是1级）')
    create_at: Mapped[Optional[str]] = mapped_column(String(50), comment='创建人')
    create_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='创建日期')
    update_at: Mapped[Optional[str]] = mapped_column(String(50), comment='更新人')
    update_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='更新日期')


class WAttributeValue(Base):
    __tablename__ = 'w_attribute_value'
    __table_args__ = (
        PrimaryKeyConstraint('attribute_value_id', name='pk_w_attribute_value'),
        {'comment': 'xt_attribute_value 危废数据字典', 'schema': 'public'}
    )

    attribute_value_id: Mapped[int] = mapped_column(Integer, primary_key=True, comment='主键id')
    fk_attribute_item_id: Mapped[int] = mapped_column(Integer, comment='外键关联(xt_attribute_item的id)')
    attribute_value: Mapped[str] = mapped_column(String(100), comment='属性值代码值')
    attribute_code: Mapped[Optional[str]] = mapped_column(String(50), comment='属性值代码')
    attribute_level: Mapped[Optional[int]] = mapped_column(Integer, comment='级别（目前都是1级）')
    description: Mapped[Optional[str]] = mapped_column(String(50))
    sort_by: Mapped[Optional[int]] = mapped_column(Integer, comment='排序')
    parent_id: Mapped[Optional[int]] = mapped_column(Integer, comment='父级id')
    status: Mapped[Optional[int]] = mapped_column(Integer, comment='状态：1有效；0无效')
    create_at: Mapped[Optional[str]] = mapped_column(String(50), comment='创建人')
    create_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='创建日期')
    update_at: Mapped[Optional[str]] = mapped_column(String(50), comment='更新人')
    update_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='更新日期')


class WBaseCaskCategory(Base):
    __tablename__ = 'w_base_cask_category'
    __table_args__ = (
        PrimaryKeyConstraint('cask_id', name='pk_w_base_cask_category'),
        {'comment': 'base_cask_category 容器类型', 'schema': 'public'}
    )

    cask_id: Mapped[int] = mapped_column(Integer, Sequence('w_cask_id', schema='public'), primary_key=True, comment='id(自增)')
    cask_name: Mapped[str] = mapped_column(String(50), comment='容器名称')
    container_type: Mapped[int] = mapped_column(Integer, comment='容器类型(w_attribute_value.PARENT_ID=-44)')
    net_weight: Mapped[str] = mapped_column(String(50), comment='容器皮重')
    cask_status: Mapped[int] = mapped_column(Integer, comment='状态：1有效；0无效')
    cask_code: Mapped[Optional[str]] = mapped_column(String(50), comment='容器编号')
    warring_weight: Mapped[Optional[str]] = mapped_column(String(50), comment='报警容量%')
    cask_level: Mapped[Optional[int]] = mapped_column(Integer, comment='级别：一级或二级')
    parent_id: Mapped[Optional[int]] = mapped_column(Integer, comment='父级id')
    remark: Mapped[Optional[str]] = mapped_column(String(255))
    create_at: Mapped[Optional[str]] = mapped_column(String(50), comment='创建人员')
    create_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='创建时间')
    update_at: Mapped[Optional[str]] = mapped_column(String(50), comment='修改人员')
    update_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')


class WBaseDistrict(Base):
    __tablename__ = 'w_base_district'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='pk_w_base_district'),
        {'comment': '危废地区资料', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True, comment='地区编号')
    name: Mapped[str] = mapped_column(String(100), comment='地区名称')
    level: Mapped[int] = mapped_column(Integer, comment='层级')
    upid: Mapped[Optional[int]] = mapped_column(Integer)
    center_longitude: Mapped[Optional[str]] = mapped_column(String(100))
    center_latitude: Mapped[Optional[str]] = mapped_column(String(100))
    map_url_type: Mapped[Optional[int]] = mapped_column(Integer)
    code: Mapped[Optional[str]] = mapped_column(String(100))
    create_at: Mapped[Optional[str]] = mapped_column(String(50), comment='创建人')
    create_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='创建日期')
    update_at: Mapped[Optional[str]] = mapped_column(String(50), comment='更新人')
    update_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='更新日期')


class WBaseRepo(Base):
    __tablename__ = 'w_base_repo'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='pk_w_base_repo'),
        {'comment': 'base_repo 贮存地点', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, Sequence('w_base_repo_id', schema='public'), primary_key=True, comment='主键id')
    repo_name: Mapped[str] = mapped_column(String(100), comment='仓库名称')
    manager_name: Mapped[str] = mapped_column(String(50), comment='负责人')
    enterprise_id: Mapped[Optional[int]] = mapped_column(Integer, comment='企业id')
    capacity: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='容量（吨）')
    create_at: Mapped[Optional[str]] = mapped_column(String(50), comment='创建人')
    create_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='创建日期')
    update_at: Mapped[Optional[str]] = mapped_column(String(50), comment='更新人')
    update_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='更新日期')


class WBaseWasteCategory(Base):
    __tablename__ = 'w_base_waste_category'
    __table_args__ = (
        PrimaryKeyConstraint('waste_category_id', name='pk_w_base_waste_category'),
        UniqueConstraint('category_code', name='category_code'),
        {'comment': 'base_cask_category 危废品类型', 'schema': 'public'}
    )

    waste_category_id: Mapped[int] = mapped_column(Integer, Sequence('w_waste_category_id', schema='public'), primary_key=True, comment='id(自增)')
    category_name: Mapped[str] = mapped_column(String(100), comment='危废类别名称')
    category_code: Mapped[str] = mapped_column(String(30), comment='危废类别代码')
    status: Mapped[int] = mapped_column(Integer, comment='状态：1有效；0无效')
    create_at: Mapped[Optional[str]] = mapped_column(String(50), comment='创建人员')
    create_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='创建时间')
    update_at: Mapped[Optional[str]] = mapped_column(String(50), comment='修改人员')
    update_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')


class WBaseWasteCategoryMapping(Base):
    __tablename__ = 'w_base_waste_category_mapping'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='pk_w_base_waste_category_mappi'),
        {'comment': 'base_waste_category_mapping 危废代码', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, Sequence('w_base_category_mapping_id', schema='public'), primary_key=True, comment='自增ID')
    waste_category_id: Mapped[int] = mapped_column(Integer, comment='危废类别id(外键)')
    industry_source: Mapped[Optional[str]] = mapped_column(String(100), comment='行业来源')
    waste_code: Mapped[Optional[str]] = mapped_column(String(100), comment='危废代码')
    category_description: Mapped[Optional[str]] = mapped_column(String(250), comment='危险危废')
    characteristics: Mapped[Optional[str]] = mapped_column(String(30), comment='危险特性')
    shape: Mapped[Optional[str]] = mapped_column(String(50), comment='暂时不用')
    component: Mapped[Optional[str]] = mapped_column(String(200), comment='主要危险成分')
    status: Mapped[Optional[int]] = mapped_column(Integer, comment='状态：1有效；0无效')
    create_at: Mapped[Optional[str]] = mapped_column(String(50), comment='创建人员')
    create_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='创建时间')
    update_at: Mapped[Optional[str]] = mapped_column(String(50), comment='修改人员')
    update_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')


class WCustomWaste(Base):
    __tablename__ = 'w_custom_waste'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='pk_w_custom_waste'),
        Index('ix_w_custom_waste', 'fsite_no'),
        {'comment': 'tb_custom_waste 自定义危废/危废信息', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, Sequence('w_custom_waste_id', schema='public'), primary_key=True, comment='自增ID')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='所属站点(客户)')
    attribute: Mapped[int] = mapped_column(Integer, comment='是否危险废物(w_attribute_value.PARENT_ID=409)')
    waste_name: Mapped[str] = mapped_column(String(100), comment='危废名称')
    waste_type: Mapped[str] = mapped_column(String(100), comment='危废类别(w_BASE_WASTE_CATEGORY)')
    waste_code: Mapped[Optional[str]] = mapped_column(String(100), comment='危废代码(w_BASE_WASTE_CATEGORY_MAPPING)')
    status: Mapped[Optional[int]] = mapped_column(Integer, comment='状态；1有效0无效')
    description: Mapped[Optional[str]] = mapped_column(String(255), comment='危废描述')
    dangerprompt: Mapped[Optional[str]] = mapped_column(String(255), comment='危险特性(w_attribute_value.PARENT_ID=-11)')
    remark: Mapped[Optional[str]] = mapped_column(String(255), comment='备注')
    gongxu: Mapped[Optional[str]] = mapped_column(String(255), comment='产生环节')
    component: Mapped[Optional[str]] = mapped_column(String(255), comment='主要成分')
    material_state: Mapped[Optional[str]] = mapped_column(String(50), comment='物质形态(w_attribute_value.PARENT_ID=-22)')
    create_at: Mapped[Optional[str]] = mapped_column(String(50), comment='创建人')
    create_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='创建日期')
    update_at: Mapped[Optional[str]] = mapped_column(String(50), comment='更新人')
    update_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='更新日期')


class WEnterpriseBasic(Base):
    __tablename__ = 'w_enterprise_basic'
    __table_args__ = (
        PrimaryKeyConstraint('fsite_no', 'enterprise_id', name='pk_w_enterprise_basic'),
        Index('ix_w_enterprise_basic', 'fsite_no'),
        {'comment': 'qy_enterprise_basic 处置企业', 'schema': 'public'}
    )

    fsite_no: Mapped[str] = mapped_column(String(20), primary_key=True, comment='所属站点(客户)')
    enterprise_id: Mapped[int] = mapped_column(Integer, Sequence('w_enterprise_id', schema='public'), primary_key=True, comment='企业id')
    enterprise_name: Mapped[str] = mapped_column(String(100), comment='企业名称')
    industry: Mapped[Optional[int]] = mapped_column(Integer, comment='所属行业(w_attribute_value.PARENT_ID=408)')
    industry_category_code: Mapped[Optional[int]] = mapped_column(Integer, comment='企业性质(w_attribute_value.PARENT_ID=-1)')
    industry_category_type: Mapped[Optional[int]] = mapped_column(Integer, comment='企业类型(w_attribute_value.PARENT_ID=412)')
    province_id: Mapped[Optional[int]] = mapped_column(Integer, comment='所属省(w_base_district where LEVEL=1)')
    city_id: Mapped[Optional[int]] = mapped_column(Integer, comment='所属市(w_base_district where LEVEL=2)')
    street_id: Mapped[Optional[int]] = mapped_column(Integer, comment='所属区县(w_base_district where LEVEL=3)')
    owned_development_zone: Mapped[Optional[int]] = mapped_column(Integer, comment='所属开发区(w_attribute_value.PARENT_ID=406)')
    business_license_code: Mapped[Optional[str]] = mapped_column(String(100), comment='企业营业执照代码')
    business_license_code_file: Mapped[Optional[str]] = mapped_column(String(100), comment='企业营业执照附件(上传文件)')
    enterprise_kind: Mapped[Optional[int]] = mapped_column(Integer)
    address: Mapped[Optional[str]] = mapped_column(String(255), comment='地址')
    longitude: Mapped[Optional[str]] = mapped_column(String(50), comment='经度')
    latitude: Mapped[Optional[str]] = mapped_column(String(50), comment='纬度')
    link_man: Mapped[Optional[str]] = mapped_column(String(50), comment='联系人')
    phone: Mapped[Optional[str]] = mapped_column(String(50), comment='电话')
    mobile: Mapped[Optional[str]] = mapped_column(String(50), comment='手机号')
    status: Mapped[Optional[int]] = mapped_column(Integer, comment='状态(w_attribute_value.PARENT_ID=407)')
    audit_status: Mapped[Optional[int]] = mapped_column(Integer, comment='审核状态（暂时不用）')
    enterprise_type: Mapped[Optional[str]] = mapped_column(String(50), comment='企业类别（暂时不用）')
    eia_annex_file: Mapped[Optional[str]] = mapped_column(String(100), comment='环评附件(上传文件)')
    business_status: Mapped[Optional[int]] = mapped_column(Integer, comment='2待洽谈3商谈中4待签约5已签约6准备中7建设中8已完工9监管中')
    business_status_time: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime)
    yewu_name: Mapped[Optional[str]] = mapped_column(String(50), comment='对应业务员姓名')
    yewu_id: Mapped[Optional[str]] = mapped_column(String(50), comment='对应用户id')
    use_limit: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='使用期限')
    open_status: Mapped[Optional[int]] = mapped_column(Integer, comment='0 未开通，1 正在开通中')
    create_at: Mapped[Optional[str]] = mapped_column(String(50), comment='创建人员')
    create_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='创建时间')
    update_at: Mapped[Optional[str]] = mapped_column(String(50), comment='修改人员')
    update_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')


class WLabel(Base):
    __tablename__ = 'w_label'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='pk_w_label'),
        Index('ix_w_label', 'fsite_no', 'cask_id', 'fequipmentbarcode', 'fmacno', 'is_ruku', 'is_chuku', 'ruku_date', 'chuku_date'),
        {'comment': 'b_label 标签', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, Sequence('w_label_id', schema='public'), primary_key=True, comment='主键id')
    qr_code: Mapped[str] = mapped_column(String(200), comment='标签代码')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='所属站点(客户)')
    repo_id: Mapped[str] = mapped_column(String(40), comment='仓库编号')
    waste_id: Mapped[int] = mapped_column(Integer, comment='危废编号')
    fequipmentbarcode: Mapped[str] = mapped_column(String(20), comment='固定资产码')
    cask_id: Mapped[int] = mapped_column(Integer, comment='设备ID')
    fmacno: Mapped[str] = mapped_column(String(80), comment='容器序列号')
    ruku_date: Mapped[datetime.datetime] = mapped_column(DateTime, comment='入库时间')
    ruku_id: Mapped[int] = mapped_column(Integer, comment='对应入库台账id')
    fpoint_no: Mapped[Optional[str]] = mapped_column(String(20), comment='存放地点')
    danger_type: Mapped[Optional[str]] = mapped_column(String(255), comment='危险类别')
    component: Mapped[Optional[str]] = mapped_column(String(255), comment='主要成分')
    chansheng_weight: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='入库重量')
    chuku_weight: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='出库重量')
    is_chansheng: Mapped[Optional[int]] = mapped_column(Integer, comment='是否产生(1是0否)')
    is_ruku: Mapped[Optional[int]] = mapped_column(Integer, comment='是否入库(1是0否)')
    is_chuku: Mapped[Optional[int]] = mapped_column(Integer, comment='是否出库(1是0否)')
    is_baofei: Mapped[Optional[int]] = mapped_column(Integer, comment='是否报废(1是0否)')
    ruku_person: Mapped[Optional[str]] = mapped_column(String(50), comment='入库人')
    chuku_person: Mapped[Optional[str]] = mapped_column(String(50), comment='出库人')
    chuku_date: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='出库日期')
    chuku_id: Mapped[Optional[int]] = mapped_column(Integer, comment='对应出库台账id')
    enterprise_id: Mapped[Optional[int]] = mapped_column(Integer, comment='企业id')
    create_at: Mapped[Optional[str]] = mapped_column(String(50), comment='创建人')
    create_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='创建日期')
    update_at: Mapped[Optional[str]] = mapped_column(String(50), comment='更新人')
    update_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='更新日期')


class WRepositoryManager(Base):
    __tablename__ = 'w_repository_manager'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='pk_w_repository_manager'),
        Index('ix_w_repository_manager', 'weight_date', 'fsite_no', 'cask_id', 'fequipmentbarcode', 'fmacno'),
        {'comment': 'tb_repository_manager 出/入过磅单', 'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, Sequence('w_repository_manager_id', schema='public'), primary_key=True, comment='主键id')
    repo_number: Mapped[str] = mapped_column(String(40), comment='过磅编号(s_ts_nextnum=2033)')
    weight_date: Mapped[datetime.datetime] = mapped_column(DateTime, comment='过磅时间')
    weight_person: Mapped[str] = mapped_column(String(20), comment='司磅员')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='所属站点(客户)')
    repo_id: Mapped[str] = mapped_column(String(40), comment='仓库编号')
    fequipmentbarcode: Mapped[str] = mapped_column(String(20), comment='固定资产码')
    cask_id: Mapped[int] = mapped_column(Integer, comment='设备ID')
    fmacno: Mapped[str] = mapped_column(String(80), comment='容器序列号')
    waste_id: Mapped[int] = mapped_column(Integer, comment='危废编号')
    repo_type: Mapped[int] = mapped_column(Integer, comment='台账类型（1产生 2暂时不用 3入库 4暂时不用 5出库）')
    fpoint_no: Mapped[Optional[str]] = mapped_column(String(20), comment='存放地点')
    weight: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='重量')
    label_number: Mapped[Optional[int]] = mapped_column(Integer, comment='数量')
    enterprise_id: Mapped[Optional[int]] = mapped_column(Integer, comment='企业id')
    fstate: Mapped[Optional[int]] = mapped_column(Integer, comment='状态(0未确认/1已确认)')
    create_at: Mapped[Optional[str]] = mapped_column(String(50), comment='创建人员')
    create_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='创建时间')
    update_at: Mapped[Optional[str]] = mapped_column(String(50), comment='修改人员')
    update_by: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间')


class YDingdingConfig(Base):
    __tablename__ = 'y_dingding_config'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='y_wechat_enterprise_config_copy1_pkey'),
        UniqueConstraint('fsite_no', name='y_wechat_enterprise_config_copy1_fsite_no_key'),
        {'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, Sequence('y_wechat_enterprise_config_id_seq', schema='public'), primary_key=True)
    fsite_no: Mapped[Optional[str]] = mapped_column(String(32), comment='客户编号')
    selfapp_appid: Mapped[Optional[str]] = mapped_column(String(64), comment='自建应用appid')
    selfapp_secret: Mapped[Optional[str]] = mapped_column(String(64), comment='自建应用Secret')
    selfapp_agentid: Mapped[Optional[str]] = mapped_column(String(64), comment='Agentid')


class YSceneDetail(Base):
    __tablename__ = 'y_scene_detail'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='y_scene_detail_pkey'),
        {'comment': '触发场景设备执行子表', 'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='自增长ID')
    fsceneno: Mapped[int] = mapped_column(Integer, comment='场景编号 ')
    faction: Mapped[str] = mapped_column(String(20), comment='指令动作')
    fequipmenttype: Mapped[Optional[int]] = mapped_column(Integer, comment='设备类型')
    finstructions: Mapped[Optional[str]] = mapped_column(String(300), comment='指令描述')
    fequipmentbarcode: Mapped[Optional[str]] = mapped_column(String(32), comment='设备资产码')
    factiontype: Mapped[Optional[int]] = mapped_column(Integer, comment='类型(1:超标，2:达标)')
    fposition: Mapped[Optional[int]] = mapped_column(Integer, comment='设备第X只脚')


class YSceneHead(Base):
    __tablename__ = 'y_scene_head'
    __table_args__ = (
        PrimaryKeyConstraint('fsceneno', name='y_scene_head_pkey'),
        {'comment': '触发场景主表', 'schema': 'public'}
    )

    fsceneno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='场景编号')
    fscenename: Mapped[str] = mapped_column(String(80), comment='场景名称')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='所属客户')
    feuipmentid: Mapped[int] = mapped_column(Integer, comment='设备ID')
    frange: Mapped[int] = mapped_column(Integer, comment='范围级别(0学校/1楼层/2教室)')
    foperator: Mapped[str] = mapped_column(String(20), comment='操作员')
    fupddate: Mapped[datetime.datetime] = mapped_column(TIMESTAMP(precision=6), comment='修改时间')
    enable: Mapped[Optional[int]] = mapped_column(Integer, comment='1:启用，0:禁用')


class YSceneItem(Base):
    __tablename__ = 'y_scene_item'
    __table_args__ = (
        PrimaryKeyConstraint('fno', name='y_scene_item_pkey'),
        {'comment': '触发场景条件子表', 'schema': 'public'}
    )

    fno: Mapped[int] = mapped_column(Integer, primary_key=True, comment='自增长ID')
    fsceneno: Mapped[int] = mapped_column(Integer, comment='场景编号')
    fparafield: Mapped[str] = mapped_column(String(20), comment='参数字段')
    fwhere: Mapped[str] = mapped_column(String(10), comment='超标条件(>/>=/=/<=/<)')
    fvalue: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='超标值')
    fwhere2: Mapped[Optional[str]] = mapped_column(String(10), comment='达标条件(>/>=/=/<=/<)')
    fvalue2: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='达标值')
    fparafieldname: Mapped[Optional[str]] = mapped_column(String(20), comment='参数字段名称')


class YScenePoint(Base):
    __tablename__ = 'y_scene_point'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='y_scene_point_pkey'),
        {'comment': '触发场景房间子表', 'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, primary_key=True, comment='自增长ID')
    fsceneno: Mapped[int] = mapped_column(Integer, comment='场景编号')
    fpoint_no: Mapped[str] = mapped_column(String(50), comment='房间编号')


class YTcWarring(Base):
    __tablename__ = 'y_tc_warring'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='a_tc_warring_pkey'),
        {'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, Sequence('a_tc_warring_fentryid_seq', schema='public'), primary_key=True, comment='自增长ID')
    fwarringno: Mapped[int] = mapped_column(Integer, comment='报警编号 ')
    fpoint_no: Mapped[str] = mapped_column(String(20), comment='教室编号')
    fparafield: Mapped[str] = mapped_column(String(20), comment='参数字段')
    fcurnum: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='当前值')
    fbegnum: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='起始值')
    fendnum: Mapped[decimal.Decimal] = mapped_column(Numeric(12, 3), comment='起讫值')
    fdescribe: Mapped[str] = mapped_column(String(200), comment='报警说明')
    fgetdate: Mapped[datetime.datetime] = mapped_column(TIMESTAMP(precision=6), comment='产生时间')
    fsite_no: Mapped[Optional[str]] = mapped_column(String(20), comment='市/区/学校')
    fenddate: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='结束时间')
    fprocflag: Mapped[Optional[int]] = mapped_column(Integer, server_default=text('0'))
    fequipmentbarcode: Mapped[Optional[str]] = mapped_column(String(20), comment='固定资产码')


class YTsWarring(Base):
    __tablename__ = 'y_ts_warring'
    __table_args__ = (
        PrimaryKeyConstraint('fwarringno', name='a_ts_warring_pkey'),
        {'schema': 'public'}
    )

    fwarringno: Mapped[int] = mapped_column(Integer, Sequence('a_ts_warring_fwarringno_seq', schema='public'), primary_key=True, comment='编号')
    fsite_no: Mapped[str] = mapped_column(String(20), comment='市/区/学校')
    fscore_flag: Mapped[int] = mapped_column(Integer, comment='统计范围(1学校/2教室)')
    fparafield: Mapped[str] = mapped_column(String(20), comment='参数字段')
    feuipmentid: Mapped[int] = mapped_column(Integer, comment='设备ID')
    flevelno: Mapped[int] = mapped_column(Integer, comment='风险等级编号')
    fsendmsg: Mapped[int] = mapped_column(Integer, comment='是否发送消息')
    fsendemail: Mapped[int] = mapped_column(Integer, comment='是否发送邮件')
    fstate: Mapped[int] = mapped_column(Integer, comment='设定状态(1正常/0停止)')
    fbegnum: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='起始值')
    fendnum: Mapped[Optional[decimal.Decimal]] = mapped_column(Numeric(12, 3), comment='结束值')
    fdescribe: Mapped[Optional[str]] = mapped_column(String(200), comment='报警说明')
    turn: Mapped[Optional[int]] = mapped_column(Integer, comment='第几次触发')
    interval: Mapped[Optional[int]] = mapped_column(Integer, comment='报警时间间隔(单位：分钟)')
    foperator: Mapped[Optional[str]] = mapped_column(String(20), comment='操作员')
    fupddate: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP(precision=6), comment='修改时间')


class YTsWarringPoint(Base):
    __tablename__ = 'y_ts_warring_point'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='a_ts_warring_point_pkey'),
        {'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, Sequence('a_ts_warring_point_fentryid_seq', schema='public'), primary_key=True, comment='自增长ID')
    fwarringno: Mapped[int] = mapped_column(Integer, comment='报警编号')
    fpoint_no: Mapped[str] = mapped_column(String(20), comment='房间编号')


class YTsWarringUser(Base):
    __tablename__ = 'y_ts_warring_user'
    __table_args__ = (
        PrimaryKeyConstraint('fentryid', name='a_ts_warring_user_pkey'),
        {'schema': 'public'}
    )

    fentryid: Mapped[int] = mapped_column(Integer, Sequence('a_ts_warring_user_fentryid_seq', schema='public'), primary_key=True, comment='自增长ID')
    fwarringno: Mapped[int] = mapped_column(Integer, comment='报警编号')
    fuserno: Mapped[str] = mapped_column(String(20), comment='用户ID')


class YWechatEnterpriseConfig(Base):
    __tablename__ = 'y_wechat_enterprise_config'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='y_wechat_enterprise_config_pkey'),
        UniqueConstraint('fsite_no', name='fsiteno_only_one'),
        {'schema': 'public'}
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True)
    fsite_no: Mapped[Optional[str]] = mapped_column(String(32), comment='客户编号')
    address_book_appid: Mapped[Optional[str]] = mapped_column(String(64), comment='通讯录Appid')
    address_book_secret: Mapped[Optional[str]] = mapped_column(String(64), comment='通讯录Secret')
    selfapp_appid: Mapped[Optional[str]] = mapped_column(String(64), comment='自建应用appid')
    selfapp_secret: Mapped[Optional[str]] = mapped_column(String(64), comment='自建应用Secret')
    selfapp_agentid: Mapped[Optional[str]] = mapped_column(String(64), comment='Agentid')
